* [PATCH net-next 1/2] nfp: bring back support for offloading shared blocks
From: Jakub Kicinski @ 2018-07-21 4:14 UTC (permalink / raw)
To: davem; +Cc: oss-drivers, netdev, Jakub Kicinski
Now that we have offload replay infrastructure added by
commit 326367427cc0 ("net: sched: call reoffload op on block callback reg")
and flows are guaranteed to be removed correctly, we can revert
commit 951a8ee6def3 ("nfp: reject binding to shared blocks").
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: John Hurley <john.hurley@netronome.com>
---
drivers/net/ethernet/netronome/nfp/bpf/main.c | 3 ---
drivers/net/ethernet/netronome/nfp/flower/offload.c | 3 ---
include/net/pkt_cls.h | 5 -----
3 files changed, 11 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.c b/drivers/net/ethernet/netronome/nfp/bpf/main.c
index 458f49235d06..994d2b756fe1 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/main.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/main.c
@@ -195,9 +195,6 @@ static int nfp_bpf_setup_tc_block(struct net_device *netdev,
if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
return -EOPNOTSUPP;
- if (tcf_block_shared(f->block))
- return -EOPNOTSUPP;
-
switch (f->command) {
case TC_BLOCK_BIND:
return tcf_block_cb_register(f->block,
diff --git a/drivers/net/ethernet/netronome/nfp/flower/offload.c b/drivers/net/ethernet/netronome/nfp/flower/offload.c
index 43b9bf12b174..6bc8a97f7e03 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/offload.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/offload.c
@@ -631,9 +631,6 @@ static int nfp_flower_setup_tc_block(struct net_device *netdev,
if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
return -EOPNOTSUPP;
- if (tcf_block_shared(f->block))
- return -EOPNOTSUPP;
-
switch (f->command) {
case TC_BLOCK_BIND:
return tcf_block_cb_register(f->block,
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index e4252a176eec..4f405ca8346f 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -114,11 +114,6 @@ void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
{
}
-static inline bool tcf_block_shared(struct tcf_block *block)
-{
- return false;
-}
-
static inline struct Qdisc *tcf_block_q(struct tcf_block *block)
{
return NULL;
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 2/2] nfp: avoid buffer leak when FW communication fails
From: Jakub Kicinski @ 2018-07-21 4:14 UTC (permalink / raw)
To: davem; +Cc: oss-drivers, netdev, Jakub Kicinski
In-Reply-To: <20180721041439.23358-1-jakub.kicinski@netronome.com>
After device is stopped we reset the rings by moving all free buffers
to positions [0, cnt - 2], and clear the position cnt - 1 in the ring.
We then proceed to clear the read/write pointers. This means that if
we try to reset the ring again the code will assume that the next to
fill buffer is at position 0 and swap it with cnt - 1. Since we
previously cleared position cnt - 1 it will lead to leaking the first
buffer and leaving ring in a bad state.
This scenario can only happen if FW communication fails, in which case
the ring will never be used again, so the fact it's in a bad state will
not be noticed. Buffer leak is the only problem. Don't try to move
buffers in the ring if the read/write pointers indicate the ring was
never used or have already been reset.
nfp_net_clear_config_and_disable() is now fully idempotent.
Found by code inspection, FW communication failures are very rare,
and reconfiguring a live device is not common either, so it's unlikely
anyone has ever noticed the leak.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
This is arguably net material but IMHO the risk of me missing something
this could break is higher than the error actually occurring, and a
page leak on a FW communication error doesn't seem like it's worth
it at -rc6 time.. I'm happy to respin if I'm wrong!
drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
index 279b8ab8a17b..cf1704e972b7 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
@@ -1078,7 +1078,7 @@ static bool nfp_net_xdp_complete(struct nfp_net_tx_ring *tx_ring)
* @dp: NFP Net data path struct
* @tx_ring: TX ring structure
*
- * Assumes that the device is stopped
+ * Assumes that the device is stopped, must be idempotent.
*/
static void
nfp_net_tx_ring_reset(struct nfp_net_dp *dp, struct nfp_net_tx_ring *tx_ring)
@@ -1280,13 +1280,18 @@ static void nfp_net_rx_give_one(const struct nfp_net_dp *dp,
* nfp_net_rx_ring_reset() - Reflect in SW state of freelist after disable
* @rx_ring: RX ring structure
*
- * Warning: Do *not* call if ring buffers were never put on the FW freelist
- * (i.e. device was not enabled)!
+ * Assumes that the device is stopped, must be idempotent.
*/
static void nfp_net_rx_ring_reset(struct nfp_net_rx_ring *rx_ring)
{
unsigned int wr_idx, last_idx;
+ /* wr_p == rd_p means ring was never fed FL bufs. RX rings are always
+ * kept at cnt - 1 FL bufs.
+ */
+ if (rx_ring->wr_p == 0 && rx_ring->rd_p == 0)
+ return;
+
/* Move the empty entry to the end of the list */
wr_idx = D_IDX(rx_ring, rx_ring->wr_p);
last_idx = rx_ring->cnt - 1;
@@ -2508,6 +2513,8 @@ static void nfp_net_vec_clear_ring_data(struct nfp_net *nn, unsigned int idx)
/**
* nfp_net_clear_config_and_disable() - Clear control BAR and disable NFP
* @nn: NFP Net device to reconfigure
+ *
+ * Warning: must be fully idempotent.
*/
static void nfp_net_clear_config_and_disable(struct nfp_net *nn)
{
--
2.17.1
^ permalink raw reply related
* Re: [PATCH net-next v3 0/8] Make /sys/class/net per net namespace objects belong to container
From: David Miller @ 2018-07-21 6:45 UTC (permalink / raw)
To: tyhicks
Cc: gregkh, tj, stephen, dmitry.torokhov, ebiederm, linux-kernel,
netdev, bridge, containers
In-Reply-To: <1532123814-1109-1-git-send-email-tyhicks@canonical.com>
From: Tyler Hicks <tyhicks@canonical.com>
Date: Fri, 20 Jul 2018 21:56:46 +0000
> This is a revival of an older patch set from Dmitry Torokhov:
>
> https://lore.kernel.org/lkml/1471386795-32918-1-git-send-email-dmitry.torokhov@gmail.com/
>
> My submission of v2 is here:
>
> https://lore.kernel.org/lkml/1531497949-1766-1-git-send-email-tyhicks@canonical.com/
>
> Here's Dmitry's description:
...
> * Changes since v2:
...
Series applied, let's see how the build goes this time :-)
^ permalink raw reply
* Re: [PATCH 00/38] Netfilter/IPVS updates for net-next
From: David Miller @ 2018-07-21 6:33 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev
In-Reply-To: <20180720130906.27687-1-pablo@netfilter.org>
From: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Fri, 20 Jul 2018 15:08:28 +0200
> The following patchset contains Netfilter/IPVS updates for your net-next
> tree:
...
> You can pull these changes from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Pulled, thank you.
^ permalink raw reply
* Re: [PATCH net-next] net: gro: Initialize backlog NAPI's gro_list
From: David Miller @ 2018-07-21 6:34 UTC (permalink / raw)
To: stranche; +Cc: eric.dumazet, netdev, subashab
In-Reply-To: <1532130803-15674-1-git-send-email-stranche@codeaurora.org>
From: Sean Tranchetti <stranche@codeaurora.org>
Date: Fri, 20 Jul 2018 17:53:23 -0600
> @@ -9556,6 +9556,7 @@ static int __init net_dev_init(void)
>
> sd->backlog.poll = process_backlog;
> sd->backlog.weight = weight_p;
> + INIT_LIST_HEAD(&sd->backlog.gro_list);
> }
>
> dev_boot_phase = 0;
This is no longer a list, but a hash table.
I'll code up the equivalent fix, thank you.
^ permalink raw reply
* [PATCH] net: Init backlog NAPI's gro_hash.
From: David Miller @ 2018-07-21 6:38 UTC (permalink / raw)
To: netdev
Based upon a patch by Sean Tranchetti.
Fixes: d4546c2509b1 ("net: Convert GRO SKB handling to list_head.")
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/core/dev.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 4f8b92d81d10..87c42c8249ae 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6115,19 +6115,24 @@ static enum hrtimer_restart napi_watchdog(struct hrtimer *timer)
return HRTIMER_NORESTART;
}
-void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
- int (*poll)(struct napi_struct *, int), int weight)
+static void init_gro_hash(struct napi_struct *napi)
{
int i;
- INIT_LIST_HEAD(&napi->poll_list);
- hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
- napi->timer.function = napi_watchdog;
- napi->gro_bitmask = 0;
for (i = 0; i < GRO_HASH_BUCKETS; i++) {
INIT_LIST_HEAD(&napi->gro_hash[i].list);
napi->gro_hash[i].count = 0;
}
+ napi->gro_bitmask = 0;
+}
+
+void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
+ int (*poll)(struct napi_struct *, int), int weight)
+{
+ INIT_LIST_HEAD(&napi->poll_list);
+ hrtimer_init(&napi->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
+ napi->timer.function = napi_watchdog;
+ init_gro_hash(napi);
napi->skb = NULL;
napi->poll = poll;
if (weight > NAPI_POLL_WEIGHT)
@@ -9554,6 +9559,7 @@ static int __init net_dev_init(void)
sd->cpu = i;
#endif
+ init_gro_hash(&sd->backlog);
sd->backlog.poll = process_backlog;
sd->backlog.weight = weight_p;
}
--
2.17.1
^ permalink raw reply related
* Re: pull-request: bpf 2018-07-20
From: David Miller @ 2018-07-21 6:57 UTC (permalink / raw)
To: daniel; +Cc: ast, netdev
In-Reply-To: <20180720212443.7103-1-daniel@iogearbox.net>
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Fri, 20 Jul 2018 23:24:43 +0200
> The following pull-request contains BPF updates for your *net* tree.
>
> The main changes are:
>
> 1) Fix in BPF Makefile to detect llvm-objcopy in a more robust way which is
> needed for pahole's BTF converter and minor UAPI tweaks in BTF_INT_BITS()
> to shrink the mask before eventual UAPI freeze, from Martin.
>
> 2) Fix a segfault in bpftool when prog pin id has no further arguments such
> as id value or file specified, from Taeung.
>
> 3) Fix powerpc JIT handling of XADD which has jumps to exit path that would
> potentially bypass verifier expectations e.g. with subprog calls. Also add
> a test case to make sure XADD is not mangling src/dst register, from Daniel.
>
> Please consider pulling these changes from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
Pulled, thanks Daniel.
^ permalink raw reply
* Re: pull-request: bpf-next 2018-07-20
From: David Miller @ 2018-07-21 6:58 UTC (permalink / raw)
To: daniel; +Cc: ast, netdev
In-Reply-To: <20180720220110.9823-1-daniel@iogearbox.net>
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Sat, 21 Jul 2018 00:01:10 +0200
> The following pull-request contains BPF updates for your *net-next* tree.
>
> The main changes are:
>
> 1) Add sharing of BPF objects within one ASIC: this allows for reuse of
> the same program on multiple ports of a device, and therefore gains
> better code store utilization. On top of that, this now also enables
> sharing of maps between programs attached to different ports of a
> device, from Jakub.
>
> 2) Cleanup in libbpf and bpftool's Makefile to reduce unneeded feature
> detections and unused variable exports, also from Jakub.
>
> 3) First batch of RCU annotation fixes in prog array handling, i.e.
> there are several __rcu markers which are not correct as well as
> some of the RCU handling, from Roman.
>
> 4) Two fixes in BPF sample files related to checking of the prog_cnt
> upper limit from sample loader, from Dan.
>
> 5) Minor cleanup in sockmap to remove a set but not used variable,
> from Colin.
>
> Please consider pulling these changes from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
Also pulled, thank you.
^ permalink raw reply
* HI
From: Mrs Suzara Maling Wan @ 2018-07-21 8:25 UTC (permalink / raw)
--
I am Mrs Suzara i have a pending project of fulfillment to put in your
hand, i will need your support to make this ream come through, could
you le me know your interest to enable me give you further information,
and I hereby advice that you send the below mentioned information I
decided to will/donate the sum of $4.5 Million US to you for the good
work of god, and also to help the motherless and less privilege and
also forth assistance of the widows.
At the moment I cannot take an telephone calls right now due to the
fact that my relatives (that have squandered the funds agave them for
this purpose before) are around me and my health status also. I have
adjusted my will and my lawyer is aware. I have willed those properties
to you by quoting my personal file routing and account information. And
I have also notified the bank that I am willing that properties to you
for a good, effective and prudent\work.
I know I don't know you but I have been directed to do this by god.ok
Please contact this woman for more details you might not get me on line
in time contact this email; mrs.suzaramalingwan1962@gmail.com
Your full name..........
Your private telephone number..........
Your passport or identity card........
Your country....................... ...
Your occupation..............
Thank you as i wait your reply.
Yoursfaithful friand,
Mrs Suzara Maling Wan
--
--
^ permalink raw reply
* [PATCH v4 net-next 2/6] net: ethernet: ti: cpdma: fit rated channels in backward order
From: Ivan Khoronzhuk @ 2018-07-21 11:59 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: corbet, akpm, netdev, linux-doc, linux-kernel, linux-omap,
vinicius.gomes, henrik, jesus.sanchez-palencia, ilias.apalodimas,
p-varis, spatton, francois.ozog, yogeshs, nsekhar, andrew,
Ivan Khoronzhuk
In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org>
According to TRM tx rated channels should be in 7..0 order,
so correct it.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
drivers/net/ethernet/ti/davinci_cpdma.c | 31 ++++++++++++-------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index 4f1267477aa4..4236dcdd5634 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -406,37 +406,36 @@ static int cpdma_chan_fit_rate(struct cpdma_chan *ch, u32 rate,
struct cpdma_chan *chan;
u32 old_rate = ch->rate;
u32 new_rmask = 0;
- int rlim = 1;
+ int rlim = 0;
int i;
- *prio_mode = 0;
for (i = tx_chan_num(0); i < tx_chan_num(CPDMA_MAX_CHANNELS); i++) {
chan = ctlr->channels[i];
- if (!chan) {
- rlim = 0;
+ if (!chan)
continue;
- }
if (chan == ch)
chan->rate = rate;
if (chan->rate) {
- if (rlim) {
- new_rmask |= chan->mask;
- } else {
- ch->rate = old_rate;
- dev_err(ctlr->dev, "Prev channel of %dch is not rate limited\n",
- chan->chan_num);
- return -EINVAL;
- }
- } else {
- *prio_mode = 1;
- rlim = 0;
+ rlim = 1;
+ new_rmask |= chan->mask;
+ continue;
}
+
+ if (rlim)
+ goto err;
}
*rmask = new_rmask;
+ *prio_mode = rlim;
return 0;
+
+err:
+ ch->rate = old_rate;
+ dev_err(ctlr->dev, "Upper cpdma ch%d is not rate limited\n",
+ chan->chan_num);
+ return -EINVAL;
}
static u32 cpdma_chan_set_factors(struct cpdma_ctlr *ctlr,
--
2.17.1
^ permalink raw reply related
* [PATCH v4 net-next 3/6] net: ethernet: ti: cpsw: add MQPRIO Qdisc offload
From: Ivan Khoronzhuk @ 2018-07-21 11:59 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: corbet, akpm, netdev, linux-doc, linux-kernel, linux-omap,
vinicius.gomes, henrik, jesus.sanchez-palencia, ilias.apalodimas,
p-varis, spatton, francois.ozog, yogeshs, nsekhar, andrew,
Ivan Khoronzhuk
In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org>
That's possible to offload vlan to tc priority mapping with
assumption sk_prio == L2 prio.
Example:
$ ethtool -L eth0 rx 1 tx 4
$ qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
$ tc -g class show dev eth0
+---(100:ffe2) mqprio
| +---(100:3) mqprio
| +---(100:4) mqprio
|
+---(100:ffe1) mqprio
| +---(100:2) mqprio
|
+---(100:ffe0) mqprio
+---(100:1) mqprio
Here, 100:1 is txq0, 100:2 is txq1, 100:3 is txq2, 100:4 is txq3
txq0 belongs to tc0, txq1 to tc1, txq2 and txq3 to tc2
The offload part only maps L2 prio to classes of traffic, but not
to transmit queues, so to direct traffic to traffic class vlan has
to be created with appropriate egress map.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
drivers/net/ethernet/ti/cpsw.c | 82 ++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 4425b537b9dd..f099e0ed138d 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -39,6 +39,7 @@
#include <linux/sys_soc.h>
#include <linux/pinctrl/consumer.h>
+#include <net/pkt_cls.h>
#include "cpsw.h"
#include "cpsw_ale.h"
@@ -153,6 +154,8 @@ do { \
#define IRQ_NUM 2
#define CPSW_MAX_QUEUES 8
#define CPSW_CPDMA_DESCS_POOL_SIZE_DEFAULT 256
+#define CPSW_TC_NUM 4
+#define CPSW_FIFO_SHAPERS_NUM (CPSW_TC_NUM - 1)
#define CPSW_RX_VLAN_ENCAP_HDR_PRIO_SHIFT 29
#define CPSW_RX_VLAN_ENCAP_HDR_PRIO_MSK GENMASK(2, 0)
@@ -454,6 +457,7 @@ struct cpsw_priv {
u8 mac_addr[ETH_ALEN];
bool rx_pause;
bool tx_pause;
+ bool mqprio_hw;
u32 emac_port;
struct cpsw_common *cpsw;
};
@@ -1578,6 +1582,14 @@ static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_common *cpsw)
soft_reset_slave(slave);
}
+static int cpsw_tc_to_fifo(int tc, int num_tc)
+{
+ if (tc == num_tc - 1)
+ return 0;
+
+ return CPSW_FIFO_SHAPERS_NUM - tc;
+}
+
static int cpsw_ndo_open(struct net_device *ndev)
{
struct cpsw_priv *priv = netdev_priv(ndev);
@@ -2191,6 +2203,75 @@ static int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate)
return ret;
}
+static int cpsw_set_mqprio(struct net_device *ndev, void *type_data)
+{
+ struct tc_mqprio_qopt_offload *mqprio = type_data;
+ struct cpsw_priv *priv = netdev_priv(ndev);
+ struct cpsw_common *cpsw = priv->cpsw;
+ int fifo, num_tc, count, offset;
+ struct cpsw_slave *slave;
+ u32 tx_prio_map = 0;
+ int i, tc, ret;
+
+ num_tc = mqprio->qopt.num_tc;
+ if (num_tc > CPSW_TC_NUM)
+ return -EINVAL;
+
+ if (mqprio->mode != TC_MQPRIO_MODE_DCB)
+ return -EINVAL;
+
+ ret = pm_runtime_get_sync(cpsw->dev);
+ if (ret < 0) {
+ pm_runtime_put_noidle(cpsw->dev);
+ return ret;
+ }
+
+ if (num_tc) {
+ for (i = 0; i < 8; i++) {
+ tc = mqprio->qopt.prio_tc_map[i];
+ fifo = cpsw_tc_to_fifo(tc, num_tc);
+ tx_prio_map |= fifo << (4 * i);
+ }
+
+ netdev_set_num_tc(ndev, num_tc);
+ for (i = 0; i < num_tc; i++) {
+ count = mqprio->qopt.count[i];
+ offset = mqprio->qopt.offset[i];
+ netdev_set_tc_queue(ndev, i, count, offset);
+ }
+ }
+
+ if (!mqprio->qopt.hw) {
+ /* restore default configuration */
+ netdev_reset_tc(ndev);
+ tx_prio_map = TX_PRIORITY_MAPPING;
+ }
+
+ priv->mqprio_hw = mqprio->qopt.hw;
+
+ offset = cpsw->version == CPSW_VERSION_1 ?
+ CPSW1_TX_PRI_MAP : CPSW2_TX_PRI_MAP;
+
+ slave = &cpsw->slaves[cpsw_slave_index(cpsw, priv)];
+ slave_write(slave, tx_prio_map, offset);
+
+ pm_runtime_put_sync(cpsw->dev);
+
+ return 0;
+}
+
+static int cpsw_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
+ void *type_data)
+{
+ switch (type) {
+ case TC_SETUP_QDISC_MQPRIO:
+ return cpsw_set_mqprio(ndev, type_data);
+
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
static const struct net_device_ops cpsw_netdev_ops = {
.ndo_open = cpsw_ndo_open,
.ndo_stop = cpsw_ndo_stop,
@@ -2206,6 +2287,7 @@ static const struct net_device_ops cpsw_netdev_ops = {
#endif
.ndo_vlan_rx_add_vid = cpsw_ndo_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = cpsw_ndo_vlan_rx_kill_vid,
+ .ndo_setup_tc = cpsw_ndo_setup_tc,
};
static int cpsw_get_regs_len(struct net_device *ndev)
--
2.17.1
^ permalink raw reply related
* [PATCH v4 net-next 5/6] net: ethernet: ti: cpsw: restore shaper configuration while down/up
From: Ivan Khoronzhuk @ 2018-07-21 11:59 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: corbet, akpm, netdev, linux-doc, linux-kernel, linux-omap,
vinicius.gomes, henrik, jesus.sanchez-palencia, ilias.apalodimas,
p-varis, spatton, francois.ozog, yogeshs, nsekhar, andrew,
Ivan Khoronzhuk
In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org>
Need to restore shapers configuration after interface was down/up.
This is needed as appropriate configuration is still replicated in
kernel settings. This only shapers context restore, so vlan
configuration should be restored by user if needed, especially for
devices with one port where vlan frames are sent via ALE.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
drivers/net/ethernet/ti/cpsw.c | 47 ++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 449dc7f1e5f8..171abcfb6184 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1808,6 +1808,51 @@ static int cpsw_set_cbs(struct net_device *ndev,
return ret;
}
+static void cpsw_cbs_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
+{
+ int fifo, bw;
+
+ for (fifo = CPSW_FIFO_SHAPERS_NUM; fifo > 0; fifo--) {
+ bw = priv->fifo_bw[fifo];
+ if (!bw)
+ continue;
+
+ cpsw_set_fifo_rlimit(priv, fifo, bw);
+ }
+}
+
+static void cpsw_mqprio_resume(struct cpsw_slave *slave, struct cpsw_priv *priv)
+{
+ struct cpsw_common *cpsw = priv->cpsw;
+ u32 tx_prio_map = 0;
+ int i, tc, fifo;
+ u32 tx_prio_rg;
+
+ if (!priv->mqprio_hw)
+ return;
+
+ for (i = 0; i < 8; i++) {
+ tc = netdev_get_prio_tc_map(priv->ndev, i);
+ fifo = CPSW_FIFO_SHAPERS_NUM - tc;
+ tx_prio_map |= fifo << (4 * i);
+ }
+
+ tx_prio_rg = cpsw->version == CPSW_VERSION_1 ?
+ CPSW1_TX_PRI_MAP : CPSW2_TX_PRI_MAP;
+
+ slave_write(slave, tx_prio_map, tx_prio_rg);
+}
+
+/* restore resources after port reset */
+static void cpsw_restore(struct cpsw_priv *priv)
+{
+ /* restore MQPRIO offload */
+ for_each_slave(priv, cpsw_mqprio_resume, priv);
+
+ /* restore CBS offload */
+ for_each_slave(priv, cpsw_cbs_resume, priv);
+}
+
static int cpsw_ndo_open(struct net_device *ndev)
{
struct cpsw_priv *priv = netdev_priv(ndev);
@@ -1887,6 +1932,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
}
+ cpsw_restore(priv);
+
/* Enable Interrupt pacing if configured */
if (cpsw->coal_intvl != 0) {
struct ethtool_coalesce coal;
--
2.17.1
^ permalink raw reply related
* [PATCH v4 net-next 6/6] Documentation: networking: cpsw: add MQPRIO & CBS offload examples
From: Ivan Khoronzhuk @ 2018-07-21 11:59 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: corbet, akpm, netdev, linux-doc, linux-kernel, linux-omap,
vinicius.gomes, henrik, jesus.sanchez-palencia, ilias.apalodimas,
p-varis, spatton, francois.ozog, yogeshs, nsekhar, andrew,
Ivan Khoronzhuk
In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org>
This document describes MQPRIO and CBS Qdisc offload configuration
for cpsw driver based on examples. It potentially can be used in
audio video bridging (AVB) and time sensitive networking (TSN).
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
Documentation/networking/ti-cpsw.txt | 540 +++++++++++++++++++++++++++
1 file changed, 540 insertions(+)
create mode 100644 Documentation/networking/ti-cpsw.txt
diff --git a/Documentation/networking/ti-cpsw.txt b/Documentation/networking/ti-cpsw.txt
new file mode 100644
index 000000000000..1e840346cae1
--- /dev/null
+++ b/Documentation/networking/ti-cpsw.txt
@@ -0,0 +1,540 @@
+* Texas Instruments CPSW ethernet driver
+
+Multiqueue & CBS & MQPRIO
+=====================================================================
+=====================================================================
+
+The cpsw has 3 CBS shapers for each external ports. This document
+describes MQPRIO and CBS Qdisc offload configuration for cpsw driver
+based on examples. It potentially can be used in audio video bridging
+(AVB) and time sensitive networking (TSN).
+
+The following examples was tested on AM572x EVM and BBB boards.
+
+Test setup
+==========
+
+Under consideration two examples with AM52xx EVM running cpsw driver
+in dual_emac mode.
+
+Several prerequisites:
+- TX queues must be rated starting from txq0 that has highest priority
+- Traffic classes are used starting from 0, that has highest priority
+- CBS shapers should be used with rated queues
+- The bandwidth for CBS shapers has to be set a little bit more then
+ potential incoming rate, thus, rate of all incoming tx queues has
+ to be a little less
+- Real rates can differ, due to discreetness
+- Map skb-priority to txq is not enough, also skb-priority to l2 prio
+ map has to be created with ip or vconfig tool
+- Any l2/socket prio (0 - 7) for classes can be used, but for
+ simplicity default values are used: 3 and 2
+- only 2 classes tested: A and B, but checked and can work with more,
+ maximum allowed 4, but only for 3 rate can be set.
+
+Test setup for examples
+=======================
+ +-------------------------------+
+ |--+ |
+ | | Workstation0 |
+ |E | MAC 18:03:73:66:87:42 |
++-----------------------------+ +--|t | |
+| | 1 | E | | |h |./tsn_listener -d \ |
+| Target board: | 0 | t |--+ |0 | 18:03:73:66:87:42 -i eth0 \|
+| AM572x EVM | 0 | h | | | -s 1500 |
+| | 0 | 0 | |--+ |
+| Only 2 classes: |Mb +---| +-------------------------------+
+| class A, class B | |
+| | +---| +-------------------------------+
+| | 1 | E | |--+ |
+| | 0 | t | | | Workstation1 |
+| | 0 | h |--+ |E | MAC 20:cf:30:85:7d:fd |
+| |Mb | 1 | +--|t | |
++-----------------------------+ |h |./tsn_listener -d \ |
+ |0 | 20:cf:30:85:7d:fd -i eth0 \|
+ | | -s 1500 |
+ |--+ |
+ +-------------------------------+
+
+*********************************************************************
+*********************************************************************
+*********************************************************************
+Example 1: One port tx AVB configuration scheme for target board
+----------------------------------------------------------------------
+(prints and scheme for AM52xx evm, applicable for single port boards)
+
+tc - traffic class
+txq - transmit queue
+p - priority
+f - fifo (cpsw fifo)
+S - shaper configured
+
++------------------------------------------------------------------+ u
+| +---------------+ +---------------+ +------+ +------+ | s
+| | | | | | | | | | e
+| | App 1 | | App 2 | | Apps | | Apps | | r
+| | Class A | | Class B | | Rest | | Rest | |
+| | Eth0 | | Eth0 | | Eth0 | | Eth1 | | s
+| | VLAN100 | | VLAN100 | | | | | | | | p
+| | 40 Mb/s | | 20 Mb/s | | | | | | | | a
+| | SO_PRIORITY=3 | | SO_PRIORITY=2 | | | | | | | | c
+| | | | | | | | | | | | | | e
+| +---|-----------+ +---|-----------+ +---|--+ +---|--+ |
++-----|------------------|------------------|--------|-------------+
+ +-+ +------------+ | |
+ | | +-----------------+ +--+
+ | | | |
++---|-------|-------------|-----------------------|----------------+
+| +----+ +----+ +----+ +----+ +----+ |
+| | p3 | | p2 | | p1 | | p0 | | p0 | | k
+| \ / \ / \ / \ / \ / | e
+| \ / \ / \ / \ / \ / | r
+| \/ \/ \/ \/ \/ | n
+| | | | | | e
+| | | +-----+ | | l
+| | | | | |
+| +----+ +----+ +----+ +----+ | s
+| |tc0 | |tc1 | |tc2 | |tc0 | | p
+| \ / \ / \ / \ / | a
+| \ / \ / \ / \ / | c
+| \/ \/ \/ \/ | e
+| | | +-----+ | |
+| | | | | | |
+| | | | | | |
+| | | | | | |
+| +----+ +----+ +----+ +----+ +----+ |
+| |txq0| |txq1| |txq2| |txq3| |txq4| |
+| \ / \ / \ / \ / \ / |
+| \ / \ / \ / \ / \ / |
+| \/ \/ \/ \/ \/ |
+| +-|------|------|------|--+ +--|--------------+ |
+| | | | | | | Eth0.100 | | Eth1 | |
++---|------|------|------|------------------------|----------------+
+ | | | | |
+ p p p p |
+ 3 2 0-1, 4-7 <- L2 priority |
+ | | | | |
+ | | | | |
++---|------|------|------|------------------------|----------------+
+| | | | | |----------+ |
+| +----+ +----+ +----+ +----+ +----+ |
+| |dma7| |dma6| |dma5| |dma4| |dma3| |
+| \ / \ / \ / \ / \ / | c
+| \S / \S / \ / \ / \ / | p
+| \/ \/ \/ \/ \/ | s
+| | | | +----- | | w
+| | | | | | |
+| | | | | | | d
+| +----+ +----+ +----+p p+----+ | r
+| | | | | | |o o| | | i
+| | f3 | | f2 | | f0 |r r| f0 | | v
+| |tc0 | |tc1 | |tc2 |t t|tc0 | | e
+| \CBS / \CBS / \CBS /1 2\CBS / | r
+| \S / \S / \ / \ / |
+| \/ \/ \/ \/ |
++------------------------------------------------------------------+
+========================================Eth==========================>
+
+1)
+// Add 4 tx queues, for interface Eth0, and 1 tx queue for Eth1
+$ ethtool -L eth0 rx 1 tx 5
+rx unmodified, ignoring
+
+2)
+// Check if num of queues is set correctly:
+$ ethtool -l eth0
+Channel parameters for eth0:
+Pre-set maximums:
+RX: 8
+TX: 8
+Other: 0
+Combined: 0
+Current hardware settings:
+RX: 1
+TX: 5
+Other: 0
+Combined: 0
+
+3)
+// TX queues must be rated starting from 0, so set bws for tx0 and tx1
+// Set rates 40 and 20 Mb/s appropriately.
+// Pay attention, real speed can differ a bit due to discreetness.
+// Leave last 2 tx queues not rated.
+$ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate
+$ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate
+
+4)
+// Check maximum rate of tx (cpdma) queues:
+$ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate
+40
+20
+0
+0
+0
+
+5)
+// Map skb->priority to traffic class:
+// 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
+// Map traffic class to transmit queue:
+// tc0 -> txq0, tc1 -> txq1, tc2 -> (txq2, txq3)
+$ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
+map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
+
+5a)
+// As two interface sharing same set of tx queues, assign all traffic
+// coming to interface Eth1 to separate queue in order to not mix it
+// with traffic from interface Eth0, so use separate txq to send
+// packets to Eth1, so all prio -> tc0 and tc0 -> txq4
+// Here hw 0, so here still default configuration for eth1 in hw
+$ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 1 \
+map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues 1@4 hw 0
+
+6)
+// Check classes settings
+$ tc -g class show dev eth0
++---(100:ffe2) mqprio
+| +---(100:3) mqprio
+| +---(100:4) mqprio
+|
++---(100:ffe1) mqprio
+| +---(100:2) mqprio
+|
++---(100:ffe0) mqprio
+ +---(100:1) mqprio
+
+$ tc -g class show dev eth1
++---(100:ffe0) mqprio
+ +---(100:5) mqprio
+
+7)
+// Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc
+// Set it +1 Mb for reserve (important!)
+// here only idle slope is important, others arg are ignored
+// Pay attention, real speed can differ a bit due to discreetness
+$ tc qdisc add dev eth0 parent 100:1 cbs locredit -1438 \
+hicredit 62 sendslope -959000 idleslope 41000 offload 1
+net eth0: set FIFO3 bw = 50
+
+8)
+// Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc:
+// Set it +1 Mb for reserve (important!)
+$ tc qdisc add dev eth0 parent 100:2 cbs locredit -1468 \
+hicredit 65 sendslope -979000 idleslope 21000 offload 1
+net eth0: set FIFO2 bw = 30
+
+9)
+// Create vlan 100 to map sk->priority to vlan qos
+$ ip link add link eth0 name eth0.100 type vlan id 100
+8021q: 802.1Q VLAN Support v1.8
+8021q: adding VLAN 0 to HW filter on device eth0
+8021q: adding VLAN 0 to HW filter on device eth1
+net eth0: Adding vlanid 100 to vlan filter
+
+10)
+// Map skb->priority to L2 prio, 1 to 1
+$ ip link set eth0.100 type vlan \
+egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
+
+11)
+// Check egress map for vlan 100
+$ cat /proc/net/vlan/eth0.100
+[...]
+INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
+EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
+
+12)
+// Run your appropriate tools with socket option "SO_PRIORITY"
+// to 3 for class A and/or to 2 for class B
+// (I took at https://www.spinics.net/lists/netdev/msg460869.html)
+./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500&
+./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500&
+
+13)
+// run your listener on workstation (should be in same vlan)
+// (I took at https://www.spinics.net/lists/netdev/msg460869.html)
+./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39000 kbps
+
+14)
+// Restore default configuration if needed
+$ ip link del eth0.100
+$ tc qdisc del dev eth1 root
+$ tc qdisc del dev eth0 root
+net eth0: Prev FIFO2 is shaped
+net eth0: set FIFO3 bw = 0
+net eth0: set FIFO2 bw = 0
+$ ethtool -L eth0 rx 1 tx 1
+
+*********************************************************************
+*********************************************************************
+*********************************************************************
+Example 2: Two port tx AVB configuration scheme for target board
+----------------------------------------------------------------------
+(prints and scheme for AM52xx evm, for dual emac boards only)
+
++------------------------------------------------------------------+ u
+| +----------+ +----------+ +------+ +----------+ +----------+ | s
+| | | | | | | | | | | | e
+| | App 1 | | App 2 | | Apps | | App 3 | | App 4 | | r
+| | Class A | | Class B | | Rest | | Class B | | Class A | |
+| | Eth0 | | Eth0 | | | | | Eth1 | | Eth1 | | s
+| | VLAN100 | | VLAN100 | | | | | VLAN100 | | VLAN100 | | p
+| | 40 Mb/s | | 20 Mb/s | | | | | 10 Mb/s | | 30 Mb/s | | a
+| | SO_PRI=3 | | SO_PRI=2 | | | | | SO_PRI=3 | | SO_PRI=2 | | c
+| | | | | | | | | | | | | | | | | e
+| +---|------+ +---|------+ +---|--+ +---|------+ +---|------+ |
++-----|-------------|-------------|---------|-------------|--------+
+ +-+ +-------+ | +----------+ +----+
+ | | +-------+------+ | |
+ | | | | | |
++---|-------|-------------|--------------|-------------|-------|---+
+| +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ |
+| | p3 | | p2 | | p1 | | p0 | | p0 | | p1 | | p2 | | p3 | | k
+| \ / \ / \ / \ / \ / \ / \ / \ / | e
+| \ / \ / \ / \ / \ / \ / \ / \ / | r
+| \/ \/ \/ \/ \/ \/ \/ \/ | n
+| | | | | | | | e
+| | | +----+ +----+ | | | l
+| | | | | | | |
+| +----+ +----+ +----+ +----+ +----+ +----+ | s
+| |tc0 | |tc1 | |tc2 | |tc2 | |tc1 | |tc0 | | p
+| \ / \ / \ / \ / \ / \ / | a
+| \ / \ / \ / \ / \ / \ / | c
+| \/ \/ \/ \/ \/ \/ | e
+| | | +-----+ +-----+ | | |
+| | | | | | | | | |
+| | | | | | | | | |
+| | | | | E E | | | | |
+| +----+ +----+ +----+ +----+ t t +----+ +----+ +----+ +----+ |
+| |txq0| |txq1| |txq4| |txq5| h h |txq6| |txq7| |txq3| |txq2| |
+| \ / \ / \ / \ / 0 1 \ / \ / \ / \ / |
+| \ / \ / \ / \ / . . \ / \ / \ / \ / |
+| \/ \/ \/ \/ 1 1 \/ \/ \/ \/ |
+| +-|------|------|------|--+ 0 0 +-|------|------|------|--+ |
+| | | | | | | 0 0 | | | | | | |
++---|------|------|------|---------------|------|------|------|----+
+ | | | | | | | |
+ p p p p p p p p
+ 3 2 0-1, 4-7 <-L2 pri-> 0-1, 4-7 2 3
+ | | | | | | | |
+ | | | | | | | |
++---|------|------|------|---------------|------|------|------|----+
+| | | | | | | | | |
+| +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ |
+| |dma7| |dma6| |dma3| |dma2| |dma1| |dma0| |dma4| |dma5| |
+| \ / \ / \ / \ / \ / \ / \ / \ / | c
+| \S / \S / \ / \ / \ / \ / \S / \S / | p
+| \/ \/ \/ \/ \/ \/ \/ \/ | s
+| | | | +----- | | | | | w
+| | | | | +----+ | | | |
+| | | | | | | | | | d
+| +----+ +----+ +----+p p+----+ +----+ +----+ | r
+| | | | | | |o o| | | | | | | i
+| | f3 | | f2 | | f0 |r CPSW r| f3 | | f2 | | f0 | | v
+| |tc0 | |tc1 | |tc2 |t t|tc0 | |tc1 | |tc2 | | e
+| \CBS / \CBS / \CBS /1 2\CBS / \CBS / \CBS / | r
+| \S / \S / \ / \S / \S / \ / |
+| \/ \/ \/ \/ \/ \/ |
++------------------------------------------------------------------+
+========================================Eth==========================>
+
+1)
+// Add 8 tx queues, for interface Eth0, but they are common, so are accessed
+// by two interfaces Eth0 and Eth1.
+$ ethtool -L eth1 rx 1 tx 8
+rx unmodified, ignoring
+
+2)
+// Check if num of queues is set correctly:
+$ ethtool -l eth0
+Channel parameters for eth0:
+Pre-set maximums:
+RX: 8
+TX: 8
+Other: 0
+Combined: 0
+Current hardware settings:
+RX: 1
+TX: 8
+Other: 0
+Combined: 0
+
+3)
+// TX queues must be rated starting from 0, so set bws for tx0 and tx1 for Eth0
+// and for tx2 and tx3 for Eth1. That is, rates 40 and 20 Mb/s appropriately
+// for Eth0 and 30 and 10 Mb/s for Eth1.
+// Real speed can differ a bit due to discreetness
+// Leave last 4 tx queues as not rated
+$ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate
+$ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate
+$ echo 30 > /sys/class/net/eth1/queues/tx-2/tx_maxrate
+$ echo 10 > /sys/class/net/eth1/queues/tx-3/tx_maxrate
+
+4)
+// Check maximum rate of tx (cpdma) queues:
+$ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate
+40
+20
+30
+10
+0
+0
+0
+0
+
+5)
+// Map skb->priority to traffic class for Eth0:
+// 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
+// Map traffic class to transmit queue:
+// tc0 -> txq0, tc1 -> txq1, tc2 -> (txq4, txq5)
+$ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
+map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@4 hw 1
+
+6)
+// Check classes settings
+$ tc -g class show dev eth0
++---(100:ffe2) mqprio
+| +---(100:5) mqprio
+| +---(100:6) mqprio
+|
++---(100:ffe1) mqprio
+| +---(100:2) mqprio
+|
++---(100:ffe0) mqprio
+ +---(100:1) mqprio
+
+7)
+// Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc for Eth0
+// here only idle slope is important, others ignored
+// Real speed can differ a bit due to discreetness
+$ tc qdisc add dev eth0 parent 100:1 cbs locredit -1470 \
+hicredit 62 sendslope -959000 idleslope 41000 offload 1
+net eth0: set FIFO3 bw = 50
+
+8)
+// Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc for Eth0
+$ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \
+hicredit 65 sendslope -979000 idleslope 21000 offload 1
+net eth0: set FIFO2 bw = 30
+
+9)
+// Create vlan 100 to map sk->priority to vlan qos for Eth0
+$ ip link add link eth0 name eth0.100 type vlan id 100
+net eth0: Adding vlanid 100 to vlan filter
+
+10)
+// Map skb->priority to L2 prio for Eth0.100, one to one
+$ ip link set eth0.100 type vlan \
+egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
+
+11)
+// Check egress map for vlan 100
+$ cat /proc/net/vlan/eth0.100
+[...]
+INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
+EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
+
+12)
+// Map skb->priority to traffic class for Eth1:
+// 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
+// Map traffic class to transmit queue:
+// tc0 -> txq2, tc1 -> txq3, tc2 -> (txq6, txq7)
+$ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 3 \
+map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@2 1@3 2@6 hw 1
+
+13)
+// Check classes settings
+$ tc -g class show dev eth1
++---(100:ffe2) mqprio
+| +---(100:7) mqprio
+| +---(100:8) mqprio
+|
++---(100:ffe1) mqprio
+| +---(100:4) mqprio
+|
++---(100:ffe0) mqprio
+ +---(100:3) mqprio
+
+14)
+// Set rate for class A - 31 Mbit (tc0, txq2) using CBS Qdisc for Eth1
+// here only idle slope is important, others ignored
+// Set it +1 Mb for reserve (important!)
+$ tc qdisc add dev eth1 parent 100:3 cbs locredit -1453 \
+hicredit 47 sendslope -969000 idleslope 31000 offload 1
+net eth1: set FIFO3 bw = 31
+
+15)
+// Set rate for class B - 11 Mbit (tc1, txq3) using CBS Qdisc for Eth1
+// Set it +1 Mb for reserve (important!)
+$ tc qdisc add dev eth1 parent 100:4 cbs locredit -1483 \
+hicredit 34 sendslope -989000 idleslope 11000 offload 1
+net eth1: set FIFO2 bw = 11
+
+16)
+// Create vlan 100 to map sk->priority to vlan qos for Eth1
+$ ip link add link eth1 name eth1.100 type vlan id 100
+net eth1: Adding vlanid 100 to vlan filter
+
+17)
+// Map skb->priority to L2 prio for Eth1.100, one to one
+$ ip link set eth1.100 type vlan \
+egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
+
+18)
+// Check egress map for vlan 100
+$ cat /proc/net/vlan/eth1.100
+[...]
+INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
+EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
+
+19)
+// Run appropriate tools with socket option "SO_PRIORITY" to 3
+// for class A and to 2 for class B. For both interfaces
+./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500&
+./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500&
+./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p2 -s 1500&
+./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p3 -s 1500&
+
+20)
+// run your listener on workstation (should be in same vlan)
+// (I took at https://www.spinics.net/lists/netdev/msg460869.html)
+./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39012 kbps
+Receiving data rate: 39000 kbps
+
+21)
+// Restore default configuration if needed
+$ ip link del eth1.100
+$ ip link del eth0.100
+$ tc qdisc del dev eth1 root
+net eth1: Prev FIFO2 is shaped
+net eth1: set FIFO3 bw = 0
+net eth1: set FIFO2 bw = 0
+$ tc qdisc del dev eth0 root
+net eth0: Prev FIFO2 is shaped
+net eth0: set FIFO3 bw = 0
+net eth0: set FIFO2 bw = 0
+$ ethtool -L eth0 rx 1 tx 1
--
2.17.1
^ permalink raw reply related
* [PATCH v4 net-next 0/6] net: ethernet: ti: cpsw: add MQPRIO and CBS Qdisc offload
From: Ivan Khoronzhuk @ 2018-07-21 11:59 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: corbet, akpm, netdev, linux-doc, linux-kernel, linux-omap,
vinicius.gomes, henrik, jesus.sanchez-palencia, ilias.apalodimas,
p-varis, spatton, francois.ozog, yogeshs, nsekhar, andrew,
Ivan Khoronzhuk
This series adds MQPRIO and CBS Qdisc offload for TI cpsw driver.
It potentially can be used in audio video bridging (AVB) and time
sensitive networking (TSN).
Patchset was tested on AM572x EVM and BBB boards. Last patch from this
series adds detailed description of configuration with examples. For
consistency reasons, in role of talker and listener, tools from
patchset "TSN: Add qdisc based config interface for CBS" were used and
can be seen here: https://www.spinics.net/lists/netdev/msg460869.html
Based on net-next/master
v4..v3:
- nothing, just rebase
v3..v2:
- corrected typo of "shaper" word, any functional changes
v2..v1:
- changed name cpsw.txt on ti-cpsw.txt
- changed name cpsw_set_tc() on cpsw_set_mqprio()
Ivan Khoronzhuk (6):
net: ethernet: ti: cpsw: use cpdma channels in backward order for txq
net: ethernet: ti: cpdma: fit rated channels in backward order
net: ethernet: ti: cpsw: add MQPRIO Qdisc offload
net: ethernet: ti: cpsw: add CBS Qdisc offload
net: ethernet: ti: cpsw: restore shaper configuration while down/up
Documentation: networking: cpsw: add MQPRIO & CBS offload examples
Documentation/networking/ti-cpsw.txt | 540 ++++++++++++++++++++++++
drivers/net/ethernet/ti/cpsw.c | 364 +++++++++++++++-
drivers/net/ethernet/ti/davinci_cpdma.c | 31 +-
3 files changed, 913 insertions(+), 22 deletions(-)
create mode 100644 Documentation/networking/ti-cpsw.txt
--
2.17.1
^ permalink raw reply
* [PATCH v4 net-next 1/6] net: ethernet: ti: cpsw: use cpdma channels in backward order for txq
From: Ivan Khoronzhuk @ 2018-07-21 11:59 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: corbet, akpm, netdev, linux-doc, linux-kernel, linux-omap,
vinicius.gomes, henrik, jesus.sanchez-palencia, ilias.apalodimas,
p-varis, spatton, francois.ozog, yogeshs, nsekhar, andrew,
Ivan Khoronzhuk
In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org>
The cpdma channel highest priority is from hi to lo number.
The driver has limited number of descriptors that are shared between
number of cpdma channels. Number of queues can be tuned with ethtool,
that allows to not spend descriptors on not needed cpdma channels.
In AVB usually only 2 tx queues can be enough with rate limitation.
The rate limitation can be used only for hi priority queues. Thus, to
use only 2 queues the 8 has to be created. It's wasteful.
So, in order to allow using only needed number of rate limited
tx queues, save resources, and be able to set rate limitation for
them, let assign tx cpdma channels in backward order to queues.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
drivers/net/ethernet/ti/cpsw.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 00761fe59848..4425b537b9dd 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -968,8 +968,8 @@ static int cpsw_tx_mq_poll(struct napi_struct *napi_tx, int budget)
/* process every unprocessed channel */
ch_map = cpdma_ctrl_txchs_state(cpsw->dma);
- for (ch = 0, num_tx = 0; ch_map; ch_map >>= 1, ch++) {
- if (!(ch_map & 0x01))
+ for (ch = 0, num_tx = 0; ch_map & 0xff; ch_map <<= 1, ch++) {
+ if (!(ch_map & 0x80))
continue;
txv = &cpsw->txv[ch];
@@ -2432,7 +2432,7 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx)
void (*handler)(void *, int, int);
struct netdev_queue *queue;
struct cpsw_vector *vec;
- int ret, *ch;
+ int ret, *ch, vch;
if (rx) {
ch = &cpsw->rx_ch_num;
@@ -2445,7 +2445,8 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx)
}
while (*ch < ch_num) {
- vec[*ch].ch = cpdma_chan_create(cpsw->dma, *ch, handler, rx);
+ vch = rx ? *ch : 7 - *ch;
+ vec[*ch].ch = cpdma_chan_create(cpsw->dma, vch, handler, rx);
queue = netdev_get_tx_queue(priv->ndev, *ch);
queue->tx_maxrate = 0;
@@ -2982,7 +2983,7 @@ static int cpsw_probe(struct platform_device *pdev)
u32 slave_offset, sliver_offset, slave_size;
const struct soc_device_attribute *soc;
struct cpsw_common *cpsw;
- int ret = 0, i;
+ int ret = 0, i, ch;
int irq;
cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL);
@@ -3157,7 +3158,8 @@ static int cpsw_probe(struct platform_device *pdev)
if (soc)
cpsw->quirk_irq = 1;
- cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0);
+ ch = cpsw->quirk_irq ? 0 : 7;
+ cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0);
if (IS_ERR(cpsw->txv[0].ch)) {
dev_err(priv->dev, "error initializing tx dma channel\n");
ret = PTR_ERR(cpsw->txv[0].ch);
--
2.17.1
^ permalink raw reply related
* [PATCH v4 net-next 4/6] net: ethernet: ti: cpsw: add CBS Qdisc offload
From: Ivan Khoronzhuk @ 2018-07-21 11:59 UTC (permalink / raw)
To: davem, grygorii.strashko
Cc: corbet, akpm, netdev, linux-doc, linux-kernel, linux-omap,
vinicius.gomes, henrik, jesus.sanchez-palencia, ilias.apalodimas,
p-varis, spatton, francois.ozog, yogeshs, nsekhar, andrew,
Ivan Khoronzhuk
In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org>
The cpsw has up to 4 FIFOs per port and upper 3 FIFOs can feed rate
limited queue with shaping. In order to set and enable shaping for
those 3 FIFOs queues the network device with CBS qdisc attached is
needed. The CBS configuration is added for dual-emac/single port mode
only, but potentially can be used in switch mode also, based on
switchdev for instance.
Despite the FIFO shapers can work w/o cpdma level shapers the base
usage must be in combine with cpdma level shapers as described in TRM,
that are set as maximum rates for interface queues with sysfs.
One of the possible configuration with txq shapers and CBS shapers:
Configured with echo RATE >
/sys/class/net/eth0/queues/tx-0/tx_maxrate
/---------------------------------------------------
/
/ cpdma level shapers
+----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+
| c7 | | c6 | | c5 | | c4 | | c3 | | c2 | | c1 | | c0 |
\ / \ / \ / \ / \ / \ / \ / \ /
\ / \ / \ / \ / \ / \ / \ / \ /
\/ \/ \/ \/ \/ \/ \/ \/
+---------|------|------|------|-------------------------------------+
| +----+ | | +---+ |
| | +----+ | | |
| v v v v |
| +----+ +----+ +----+ +----+ p p+----+ +----+ +----+ +----+ |
| | | | | | | | | o o| | | | | | | | |
| | f3 | | f2 | | f1 | | f0 | r CPSW r| f3 | | f2 | | f1 | | f0 | |
| | | | | | | | | t t| | | | | | | | |
| \ / \ / \ / \ / 0 1\ / \ / \ / \ / |
| \ X \ / \ / \ / \ / \ / \ / \ / |
| \/ \ \/ \/ \/ \/ \/ \/ \/ |
+-------\------------------------------------------------------------+
\
\ FIFO shaper, set with CBS offload added in this patch,
\ FIFO0 cannot be rate limited
------------------------------------------------------
CBS shaper configuration is supposed to be used with root MQPRIO Qdisc
offload allowing to add sk_prio->tc->txq maps that direct traffic to
appropriate tx queue and maps L2 priority to FIFO shaper.
The CBS shaper is intended to be used for AVB where L2 priority
(pcp field) is used to differentiate class of traffic. So additionally
vlan needs to be created with appropriate egress sk_prio->l2 prio map.
If CBS has several tx queues assigned to it, the sum of their
bandwidth has not overlap bandwidth set for CBS. It's recomended the
CBS bandwidth to be a little bit more.
The CBS shaper is configured with CBS qdisc offload interface using tc
tool from iproute2 packet.
For instance:
$ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
$ tc -g class show dev eth0
+---(100:ffe2) mqprio
| +---(100:3) mqprio
| +---(100:4) mqprio
|
+---(100:ffe1) mqprio
| +---(100:2) mqprio
|
+---(100:ffe0) mqprio
+---(100:1) mqprio
$ tc qdisc add dev eth0 parent 100:1 cbs locredit -1440 \
hicredit 60 sendslope -960000 idleslope 40000 offload 1
$ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \
hicredit 62 sendslope -980000 idleslope 20000 offload 1
The above code set CBS shapers for tc0 and tc1, for that txq0 and
txq1 is used. Pay attention, the real set bandwidth can differ a bit
due to discreteness of configuration parameters.
Here parameters like locredit, hicredit and sendslope are ignored
internally and are supposed to be set with assumption that maximum
frame size for frame - 1500.
It's supposed that interface speed is not changed while reconnection,
not always is true, so inform user in case speed of interface was
changed, as it can impact on dependent shapers configuration.
For more examples see Documentation.
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
drivers/net/ethernet/ti/cpsw.c | 221 +++++++++++++++++++++++++++++++++
1 file changed, 221 insertions(+)
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index f099e0ed138d..449dc7f1e5f8 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -46,6 +46,8 @@
#include "cpts.h"
#include "davinci_cpdma.h"
+#include <net/pkt_sched.h>
+
#define CPSW_DEBUG (NETIF_MSG_HW | NETIF_MSG_WOL | \
NETIF_MSG_DRV | NETIF_MSG_LINK | \
NETIF_MSG_IFUP | NETIF_MSG_INTR | \
@@ -154,8 +156,12 @@ do { \
#define IRQ_NUM 2
#define CPSW_MAX_QUEUES 8
#define CPSW_CPDMA_DESCS_POOL_SIZE_DEFAULT 256
+#define CPSW_FIFO_QUEUE_TYPE_SHIFT 16
+#define CPSW_FIFO_SHAPE_EN_SHIFT 16
+#define CPSW_FIFO_RATE_EN_SHIFT 20
#define CPSW_TC_NUM 4
#define CPSW_FIFO_SHAPERS_NUM (CPSW_TC_NUM - 1)
+#define CPSW_PCT_MASK 0x7f
#define CPSW_RX_VLAN_ENCAP_HDR_PRIO_SHIFT 29
#define CPSW_RX_VLAN_ENCAP_HDR_PRIO_MSK GENMASK(2, 0)
@@ -458,6 +464,8 @@ struct cpsw_priv {
bool rx_pause;
bool tx_pause;
bool mqprio_hw;
+ int fifo_bw[CPSW_TC_NUM];
+ int shp_cfg_speed;
u32 emac_port;
struct cpsw_common *cpsw;
};
@@ -1082,6 +1090,38 @@ static void cpsw_set_slave_mac(struct cpsw_slave *slave,
slave_write(slave, mac_lo(priv->mac_addr), SA_LO);
}
+static bool cpsw_shp_is_off(struct cpsw_priv *priv)
+{
+ struct cpsw_common *cpsw = priv->cpsw;
+ struct cpsw_slave *slave;
+ u32 shift, mask, val;
+
+ val = readl_relaxed(&cpsw->regs->ptype);
+
+ slave = &cpsw->slaves[cpsw_slave_index(cpsw, priv)];
+ shift = CPSW_FIFO_SHAPE_EN_SHIFT + 3 * slave->slave_num;
+ mask = 7 << shift;
+ val = val & mask;
+
+ return !val;
+}
+
+static void cpsw_fifo_shp_on(struct cpsw_priv *priv, int fifo, int on)
+{
+ struct cpsw_common *cpsw = priv->cpsw;
+ struct cpsw_slave *slave;
+ u32 shift, mask, val;
+
+ val = readl_relaxed(&cpsw->regs->ptype);
+
+ slave = &cpsw->slaves[cpsw_slave_index(cpsw, priv)];
+ shift = CPSW_FIFO_SHAPE_EN_SHIFT + 3 * slave->slave_num;
+ mask = (1 << --fifo) << shift;
+ val = on ? val | mask : val & ~mask;
+
+ writel_relaxed(val, &cpsw->regs->ptype);
+}
+
static void _cpsw_adjust_link(struct cpsw_slave *slave,
struct cpsw_priv *priv, bool *link)
{
@@ -1121,6 +1161,12 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave,
mac_control |= BIT(4);
*link = true;
+
+ if (priv->shp_cfg_speed &&
+ priv->shp_cfg_speed != slave->phy->speed &&
+ !cpsw_shp_is_off(priv))
+ dev_warn(priv->dev,
+ "Speed was changed, CBS shaper speeds are changed!");
} else {
mac_control = 0;
/* disable forwarding */
@@ -1590,6 +1636,178 @@ static int cpsw_tc_to_fifo(int tc, int num_tc)
return CPSW_FIFO_SHAPERS_NUM - tc;
}
+static int cpsw_set_fifo_bw(struct cpsw_priv *priv, int fifo, int bw)
+{
+ struct cpsw_common *cpsw = priv->cpsw;
+ u32 val = 0, send_pct, shift;
+ struct cpsw_slave *slave;
+ int pct = 0, i;
+
+ if (bw > priv->shp_cfg_speed * 1000)
+ goto err;
+
+ /* shaping has to stay enabled for highest fifos linearly
+ * and fifo bw no more then interface can allow
+ */
+ slave = &cpsw->slaves[cpsw_slave_index(cpsw, priv)];
+ send_pct = slave_read(slave, SEND_PERCENT);
+ for (i = CPSW_FIFO_SHAPERS_NUM; i > 0; i--) {
+ if (!bw) {
+ if (i >= fifo || !priv->fifo_bw[i])
+ continue;
+
+ dev_warn(priv->dev, "Prev FIFO%d is shaped", i);
+ continue;
+ }
+
+ if (!priv->fifo_bw[i] && i > fifo) {
+ dev_err(priv->dev, "Upper FIFO%d is not shaped", i);
+ return -EINVAL;
+ }
+
+ shift = (i - 1) * 8;
+ if (i == fifo) {
+ send_pct &= ~(CPSW_PCT_MASK << shift);
+ val = DIV_ROUND_UP(bw, priv->shp_cfg_speed * 10);
+ if (!val)
+ val = 1;
+
+ send_pct |= val << shift;
+ pct += val;
+ continue;
+ }
+
+ if (priv->fifo_bw[i])
+ pct += (send_pct >> shift) & CPSW_PCT_MASK;
+ }
+
+ if (pct >= 100)
+ goto err;
+
+ slave_write(slave, send_pct, SEND_PERCENT);
+ priv->fifo_bw[fifo] = bw;
+
+ dev_warn(priv->dev, "set FIFO%d bw = %d\n", fifo,
+ DIV_ROUND_CLOSEST(val * priv->shp_cfg_speed, 100));
+
+ return 0;
+err:
+ dev_err(priv->dev, "Bandwidth doesn't fit in tc configuration");
+ return -EINVAL;
+}
+
+static int cpsw_set_fifo_rlimit(struct cpsw_priv *priv, int fifo, int bw)
+{
+ struct cpsw_common *cpsw = priv->cpsw;
+ struct cpsw_slave *slave;
+ u32 tx_in_ctl_rg, val;
+ int ret;
+
+ ret = cpsw_set_fifo_bw(priv, fifo, bw);
+ if (ret)
+ return ret;
+
+ slave = &cpsw->slaves[cpsw_slave_index(cpsw, priv)];
+ tx_in_ctl_rg = cpsw->version == CPSW_VERSION_1 ?
+ CPSW1_TX_IN_CTL : CPSW2_TX_IN_CTL;
+
+ if (!bw)
+ cpsw_fifo_shp_on(priv, fifo, bw);
+
+ val = slave_read(slave, tx_in_ctl_rg);
+ if (cpsw_shp_is_off(priv)) {
+ /* disable FIFOs rate limited queues */
+ val &= ~(0xf << CPSW_FIFO_RATE_EN_SHIFT);
+
+ /* set type of FIFO queues to normal priority mode */
+ val &= ~(3 << CPSW_FIFO_QUEUE_TYPE_SHIFT);
+
+ /* set type of FIFO queues to be rate limited */
+ if (bw)
+ val |= 2 << CPSW_FIFO_QUEUE_TYPE_SHIFT;
+ else
+ priv->shp_cfg_speed = 0;
+ }
+
+ /* toggle a FIFO rate limited queue */
+ if (bw)
+ val |= BIT(fifo + CPSW_FIFO_RATE_EN_SHIFT);
+ else
+ val &= ~BIT(fifo + CPSW_FIFO_RATE_EN_SHIFT);
+ slave_write(slave, val, tx_in_ctl_rg);
+
+ /* FIFO transmit shape enable */
+ cpsw_fifo_shp_on(priv, fifo, bw);
+ return 0;
+}
+
+/* Defaults:
+ * class A - prio 3
+ * class B - prio 2
+ * shaping for class A should be set first
+ */
+static int cpsw_set_cbs(struct net_device *ndev,
+ struct tc_cbs_qopt_offload *qopt)
+{
+ struct cpsw_priv *priv = netdev_priv(ndev);
+ struct cpsw_common *cpsw = priv->cpsw;
+ struct cpsw_slave *slave;
+ int prev_speed = 0;
+ int tc, ret, fifo;
+ u32 bw = 0;
+
+ tc = netdev_txq_to_tc(priv->ndev, qopt->queue);
+
+ /* enable channels in backward order, as highest FIFOs must be rate
+ * limited first and for compliance with CPDMA rate limited channels
+ * that also used in bacward order. FIFO0 cannot be rate limited.
+ */
+ fifo = cpsw_tc_to_fifo(tc, ndev->num_tc);
+ if (!fifo) {
+ dev_err(priv->dev, "Last tc%d can't be rate limited", tc);
+ return -EINVAL;
+ }
+
+ /* do nothing, it's disabled anyway */
+ if (!qopt->enable && !priv->fifo_bw[fifo])
+ return 0;
+
+ /* shapers can be set if link speed is known */
+ slave = &cpsw->slaves[cpsw_slave_index(cpsw, priv)];
+ if (slave->phy && slave->phy->link) {
+ if (priv->shp_cfg_speed &&
+ priv->shp_cfg_speed != slave->phy->speed)
+ prev_speed = priv->shp_cfg_speed;
+
+ priv->shp_cfg_speed = slave->phy->speed;
+ }
+
+ if (!priv->shp_cfg_speed) {
+ dev_err(priv->dev, "Link speed is not known");
+ return -1;
+ }
+
+ ret = pm_runtime_get_sync(cpsw->dev);
+ if (ret < 0) {
+ pm_runtime_put_noidle(cpsw->dev);
+ return ret;
+ }
+
+ bw = qopt->enable ? qopt->idleslope : 0;
+ ret = cpsw_set_fifo_rlimit(priv, fifo, bw);
+ if (ret) {
+ priv->shp_cfg_speed = prev_speed;
+ prev_speed = 0;
+ }
+
+ if (bw && prev_speed)
+ dev_warn(priv->dev,
+ "Speed was changed, CBS shaper speeds are changed!");
+
+ pm_runtime_put_sync(cpsw->dev);
+ return ret;
+}
+
static int cpsw_ndo_open(struct net_device *ndev)
{
struct cpsw_priv *priv = netdev_priv(ndev);
@@ -2264,6 +2482,9 @@ static int cpsw_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
void *type_data)
{
switch (type) {
+ case TC_SETUP_QDISC_CBS:
+ return cpsw_set_cbs(ndev, type_data);
+
case TC_SETUP_QDISC_MQPRIO:
return cpsw_set_mqprio(ndev, type_data);
--
2.17.1
^ permalink raw reply related
* Re: [PATCH] [v3] infiniband: i40iw, nes: don't use wall time for TCP sequence numbers
From: Shiraz Saleem @ 2018-07-21 13:29 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Latif, Faisal, Doug Ledford, Jason Gunthorpe, David S. Miller,
Geert Uytterhoeven, Yuval Shaia, Orosco, Henry,
Nikolova, Tatyana E, Ismail, Mustafa, Jia-Ju Bai, Bart Van Assche,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
In-Reply-To: <20180709083523.448587-1-arnd@arndb.de>
On Mon, Jul 09, 2018 at 02:34:43AM -0600, Arnd Bergmann wrote:
> The nes infiniband driver uses current_kernel_time() to get a nanosecond
> granunarity timestamp to initialize its tcp sequence counters. This is
> one of only a few remaining users of that deprecated function, so we
> should try to get rid of it.
>
> Aside from using a deprecated API, there are several problems I see here:
>
> - Using a CLOCK_REALTIME based time source makes it predictable in
> case the time base is synchronized.
> - Using a coarse timestamp means it only gets updated once per jiffie,
> making it even more predictable in order to avoid having to access
> the hardware clock source
> - The upper 2 bits are always zero because the nanoseconds are at most
> 999999999.
>
> For the Linux TCP implementation, we use secure_tcp_seq(), which appears
> to be appropriate here as well, and solves all the above problems.
>
> i40iw uses a variant of the same code, so I do that same thing there
> for ipv4. Unlike nes, i40e also supports ipv6, which needs to call
> secure_tcpv6_seq instead.
>
> Acked-by: Shiraz Saleem <shiraz.saleem@intel.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: use secure_tcpv6_seq for IPv6 support as suggested by Shiraz Saleem.
> v3: add a soft IPv6 dependency to prevent a link error with CONFIG_IPV6=m,
> this now forces i40iw to be a module as well, add an IS_ENABLED()
> check to avoid calling it when IPV6 is completely disabled.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/infiniband/hw/i40iw/Kconfig | 1 +
> drivers/infiniband/hw/i40iw/i40iw_cm.c | 26 +++++++++++++++++++++-----
> drivers/infiniband/hw/nes/nes_cm.c | 8 +++++---
> net/core/secure_seq.c | 1 +
> 4 files changed, 28 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/infiniband/hw/i40iw/Kconfig b/drivers/infiniband/hw/i40iw/Kconfig
> index 2962979c06e9..d867ef1ac72a 100644
> --- a/drivers/infiniband/hw/i40iw/Kconfig
> +++ b/drivers/infiniband/hw/i40iw/Kconfig
> @@ -1,6 +1,7 @@
> config INFINIBAND_I40IW
> tristate "Intel(R) Ethernet X722 iWARP Driver"
> depends on INET && I40E
> + depends on IPV6 || !IPV6
> depends on PCI
> select GENERIC_ALLOCATOR
> ---help---
v3 update looks ok. Thanks!
^ permalink raw reply
* Re: [PATCH bpf] xdp: add NULL pointer check in __xdp_return()
From: Taehee Yoo @ 2018-07-21 12:56 UTC (permalink / raw)
To: Martin KaFai Lau; +Cc: daniel, ast, bjorn.topel, brouer, netdev
In-Reply-To: <20180720171821.ivtpo6obzx2v737c@kafai-mbp.dhcp.thefacebook.com>
2018-07-21 2:18 GMT+09:00 Martin KaFai Lau <kafai@fb.com>:
> On Sat, Jul 21, 2018 at 01:04:45AM +0900, Taehee Yoo wrote:
>> rhashtable_lookup() can return NULL. so that NULL pointer
>> check routine should be added.
>>
>> Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY")
>> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
>> ---
>> net/core/xdp.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/core/xdp.c b/net/core/xdp.c
>> index 9d1f220..1c12bc7 100644
>> --- a/net/core/xdp.c
>> +++ b/net/core/xdp.c
>> @@ -345,7 +345,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
>> rcu_read_lock();
>> /* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */
>> xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
>> - xa->zc_alloc->free(xa->zc_alloc, handle);
>> + if (xa)
>> + xa->zc_alloc->free(xa->zc_alloc, handle);
> hmm...It is not clear to me the "!xa" case don't have to be handled?
Thank you for reviewing!
Returning NULL pointer is bug case such as calling after use
xdp_rxq_info_unreg().
so that, I think it can't handle at that moment.
we can make __xdp_return to add WARN_ON_ONCE() or
add return error code to driver.
But I'm not sure if these is useful information.
I might have misunderstood scenario of MEM_TYPE_ZERO_COPY
because there is no use case of MEM_TYPE_ZERO_COPY yet.
Thanks!
>
>> rcu_read_unlock();
>> default:
>> /* Not possible, checked in xdp_rxq_info_reg_mem_model() */
>> --
>> 2.9.3
>>
^ permalink raw reply
* [PATCH v2 net-next] net: phy: add GBit master / slave error detection
From: Heiner Kallweit @ 2018-07-21 13:48 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
Certain PHY's have issues when operating in GBit slave mode and can
be forced to master mode. Examples are RTL8211C, also the Micrel PHY
driver has a DT setting to force master mode.
If two such chips are link partners the autonegotiation will fail.
Standard defines a self-clearing on read, latched-high bit to
indicate this error. Check this bit to inform the user.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- Use different error messages depending on whether local PHY uses
manual master/slave configuration.
---
drivers/net/phy/phy_device.c | 8 ++++++++
include/uapi/linux/mii.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b9f5f40a..db1172db 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1555,6 +1555,14 @@ int genphy_read_status(struct phy_device *phydev)
if (adv < 0)
return adv;
+ if (lpagb & LPA_1000MSFAIL) {
+ if (adv & CTL1000_ENABLE_MASTER)
+ phydev_err(phydev, "Master/Slave resolution failed, maybe conflicting manual settings?\n");
+ else
+ phydev_err(phydev, "Master/Slave resolution failed\n");
+ return -ENOLINK;
+ }
+
phydev->lp_advertising =
mii_stat1000_to_ethtool_lpa_t(lpagb);
common_adv_gb = lpagb & adv << 2;
diff --git a/include/uapi/linux/mii.h b/include/uapi/linux/mii.h
index b5c2fdcf..a5062165 100644
--- a/include/uapi/linux/mii.h
+++ b/include/uapi/linux/mii.h
@@ -136,6 +136,7 @@
#define CTL1000_ENABLE_MASTER 0x1000
/* 1000BASE-T Status register */
+#define LPA_1000MSFAIL 0x8000 /* Master/Slave resolution failure */
#define LPA_1000LOCALRXOK 0x2000 /* Link partner local receiver status */
#define LPA_1000REMRXOK 0x1000 /* Link partner remote receiver status */
#define LPA_1000FULL 0x0800 /* Link partner 1000BASE-T full duplex */
--
2.18.0
^ permalink raw reply related
* [PATCH net-next 1/2] net: phy: add helper phy_polling_mode
From: Heiner Kallweit @ 2018-07-21 13:51 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
Add a helper for checking whether polling is used to detect PHY status
changes.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/phy.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 075c2f77..cd6f637c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -824,6 +824,16 @@ static inline bool phy_interrupt_is_valid(struct phy_device *phydev)
return phydev->irq != PHY_POLL && phydev->irq != PHY_IGNORE_INTERRUPT;
}
+/**
+ * phy_polling_mode - Convenience function for testing whether polling is
+ * used to detect PHY status changes
+ * @phydev: the phy_device struct
+ */
+static inline bool phy_polling_mode(struct phy_device *phydev)
+{
+ return phydev->irq == PHY_POLL;
+}
+
/**
* phy_is_internal - Convenience function for testing if a PHY is internal
* @phydev: the phy_device struct
--
2.18.0
^ permalink raw reply related
* [PATCH net-next 2/2] net: phy: use helper phy_polling_mode
From: Heiner Kallweit @ 2018-07-21 13:53 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, David Miller; +Cc: netdev@vger.kernel.org
In-Reply-To: <18b53769-e444-663d-650d-5887b3ae53ad@gmail.com>
Make use of new helper phy_polling_mode().
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 914fe8e6..7ade22a7 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -519,7 +519,7 @@ static int phy_start_aneg_priv(struct phy_device *phydev, bool sync)
* negotiation may already be done and aneg interrupt may not be
* generated.
*/
- if (phydev->irq != PHY_POLL && phydev->state == PHY_AN) {
+ if (!phy_polling_mode(phydev) && phydev->state == PHY_AN) {
err = phy_aneg_done(phydev);
if (err > 0) {
trigger = true;
@@ -977,7 +977,7 @@ void phy_state_machine(struct work_struct *work)
needs_aneg = true;
break;
case PHY_NOLINK:
- if (phydev->irq != PHY_POLL)
+ if (!phy_polling_mode(phydev))
break;
err = phy_read_status(phydev);
@@ -1018,7 +1018,7 @@ void phy_state_machine(struct work_struct *work)
/* Only register a CHANGE if we are polling and link changed
* since latest checking.
*/
- if (phydev->irq == PHY_POLL) {
+ if (phy_polling_mode(phydev)) {
old_link = phydev->link;
err = phy_read_status(phydev);
if (err)
@@ -1117,7 +1117,7 @@ void phy_state_machine(struct work_struct *work)
* PHY, if PHY_IGNORE_INTERRUPT is set, then we will be moving
* between states from phy_mac_interrupt()
*/
- if (phydev->irq == PHY_POLL)
+ if (phy_polling_mode(phydev))
queue_delayed_work(system_power_efficient_wq, &phydev->state_queue,
PHY_STATE_TIME * HZ);
}
--
2.18.0
^ permalink raw reply related
* Re: [PATCH v4 net-next 6/6] Documentation: networking: cpsw: add MQPRIO & CBS offload examples
From: Richard Cochran @ 2018-07-21 15:10 UTC (permalink / raw)
To: Ivan Khoronzhuk
Cc: davem, grygorii.strashko, corbet, akpm, netdev, linux-doc,
linux-kernel, linux-omap, vinicius.gomes, henrik,
jesus.sanchez-palencia, ilias.apalodimas, p-varis, spatton,
francois.ozog, yogeshs, nsekhar, andrew
In-Reply-To: <20180721115923.1389-7-ivan.khoronzhuk@linaro.org>
On Sat, Jul 21, 2018 at 02:59:23PM +0300, Ivan Khoronzhuk wrote:
> This document describes MQPRIO and CBS Qdisc offload configuration
> for cpsw driver based on examples. It potentially can be used in
> audio video bridging (AVB) and time sensitive networking (TSN).
>
> Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> ---
> Documentation/networking/ti-cpsw.txt | 540 +++++++++++++++++++++++++++
> 1 file changed, 540 insertions(+)
> create mode 100644 Documentation/networking/ti-cpsw.txt
>
> diff --git a/Documentation/networking/ti-cpsw.txt b/Documentation/networking/ti-cpsw.txt
> new file mode 100644
> index 000000000000..1e840346cae1
> --- /dev/null
> +++ b/Documentation/networking/ti-cpsw.txt
> @@ -0,0 +1,540 @@
> +* Texas Instruments CPSW ethernet driver
> +
> +Multiqueue & CBS & MQPRIO
> +=====================================================================
> +=====================================================================
> +
> +The cpsw has 3 CBS shapers for each external ports. This document
> +describes MQPRIO and CBS Qdisc offload configuration for cpsw driver
> +based on examples. It potentially can be used in audio video bridging
> +(AVB) and time sensitive networking (TSN).
> +
> +The following examples was tested on AM572x EVM and BBB boards.
> +
> +Test setup
> +==========
> +
> +Under consideration two examples with AM52xx EVM running cpsw driver
> +in dual_emac mode.
s/AM52xx/AM572x ?
Also, there are more mentions of AM52xx, below.
Thanks,
Richard
> +
> +Several prerequisites:
> +- TX queues must be rated starting from txq0 that has highest priority
> +- Traffic classes are used starting from 0, that has highest priority
> +- CBS shapers should be used with rated queues
> +- The bandwidth for CBS shapers has to be set a little bit more then
> + potential incoming rate, thus, rate of all incoming tx queues has
> + to be a little less
> +- Real rates can differ, due to discreetness
> +- Map skb-priority to txq is not enough, also skb-priority to l2 prio
> + map has to be created with ip or vconfig tool
> +- Any l2/socket prio (0 - 7) for classes can be used, but for
> + simplicity default values are used: 3 and 2
> +- only 2 classes tested: A and B, but checked and can work with more,
> + maximum allowed 4, but only for 3 rate can be set.
> +
> +Test setup for examples
> +=======================
> + +-------------------------------+
> + |--+ |
> + | | Workstation0 |
> + |E | MAC 18:03:73:66:87:42 |
> ++-----------------------------+ +--|t | |
> +| | 1 | E | | |h |./tsn_listener -d \ |
> +| Target board: | 0 | t |--+ |0 | 18:03:73:66:87:42 -i eth0 \|
> +| AM572x EVM | 0 | h | | | -s 1500 |
> +| | 0 | 0 | |--+ |
> +| Only 2 classes: |Mb +---| +-------------------------------+
> +| class A, class B | |
> +| | +---| +-------------------------------+
> +| | 1 | E | |--+ |
> +| | 0 | t | | | Workstation1 |
> +| | 0 | h |--+ |E | MAC 20:cf:30:85:7d:fd |
> +| |Mb | 1 | +--|t | |
> ++-----------------------------+ |h |./tsn_listener -d \ |
> + |0 | 20:cf:30:85:7d:fd -i eth0 \|
> + | | -s 1500 |
> + |--+ |
> + +-------------------------------+
> +
> +*********************************************************************
> +*********************************************************************
> +*********************************************************************
> +Example 1: One port tx AVB configuration scheme for target board
> +----------------------------------------------------------------------
> +(prints and scheme for AM52xx evm, applicable for single port boards)
> +
> +tc - traffic class
> +txq - transmit queue
> +p - priority
> +f - fifo (cpsw fifo)
> +S - shaper configured
> +
> ++------------------------------------------------------------------+ u
> +| +---------------+ +---------------+ +------+ +------+ | s
> +| | | | | | | | | | e
> +| | App 1 | | App 2 | | Apps | | Apps | | r
> +| | Class A | | Class B | | Rest | | Rest | |
> +| | Eth0 | | Eth0 | | Eth0 | | Eth1 | | s
> +| | VLAN100 | | VLAN100 | | | | | | | | p
> +| | 40 Mb/s | | 20 Mb/s | | | | | | | | a
> +| | SO_PRIORITY=3 | | SO_PRIORITY=2 | | | | | | | | c
> +| | | | | | | | | | | | | | e
> +| +---|-----------+ +---|-----------+ +---|--+ +---|--+ |
> ++-----|------------------|------------------|--------|-------------+
> + +-+ +------------+ | |
> + | | +-----------------+ +--+
> + | | | |
> ++---|-------|-------------|-----------------------|----------------+
> +| +----+ +----+ +----+ +----+ +----+ |
> +| | p3 | | p2 | | p1 | | p0 | | p0 | | k
> +| \ / \ / \ / \ / \ / | e
> +| \ / \ / \ / \ / \ / | r
> +| \/ \/ \/ \/ \/ | n
> +| | | | | | e
> +| | | +-----+ | | l
> +| | | | | |
> +| +----+ +----+ +----+ +----+ | s
> +| |tc0 | |tc1 | |tc2 | |tc0 | | p
> +| \ / \ / \ / \ / | a
> +| \ / \ / \ / \ / | c
> +| \/ \/ \/ \/ | e
> +| | | +-----+ | |
> +| | | | | | |
> +| | | | | | |
> +| | | | | | |
> +| +----+ +----+ +----+ +----+ +----+ |
> +| |txq0| |txq1| |txq2| |txq3| |txq4| |
> +| \ / \ / \ / \ / \ / |
> +| \ / \ / \ / \ / \ / |
> +| \/ \/ \/ \/ \/ |
> +| +-|------|------|------|--+ +--|--------------+ |
> +| | | | | | | Eth0.100 | | Eth1 | |
> ++---|------|------|------|------------------------|----------------+
> + | | | | |
> + p p p p |
> + 3 2 0-1, 4-7 <- L2 priority |
> + | | | | |
> + | | | | |
> ++---|------|------|------|------------------------|----------------+
> +| | | | | |----------+ |
> +| +----+ +----+ +----+ +----+ +----+ |
> +| |dma7| |dma6| |dma5| |dma4| |dma3| |
> +| \ / \ / \ / \ / \ / | c
> +| \S / \S / \ / \ / \ / | p
> +| \/ \/ \/ \/ \/ | s
> +| | | | +----- | | w
> +| | | | | | |
> +| | | | | | | d
> +| +----+ +----+ +----+p p+----+ | r
> +| | | | | | |o o| | | i
> +| | f3 | | f2 | | f0 |r r| f0 | | v
> +| |tc0 | |tc1 | |tc2 |t t|tc0 | | e
> +| \CBS / \CBS / \CBS /1 2\CBS / | r
> +| \S / \S / \ / \ / |
> +| \/ \/ \/ \/ |
> ++------------------------------------------------------------------+
> +========================================Eth==========================>
> +
> +1)
> +// Add 4 tx queues, for interface Eth0, and 1 tx queue for Eth1
> +$ ethtool -L eth0 rx 1 tx 5
> +rx unmodified, ignoring
> +
> +2)
> +// Check if num of queues is set correctly:
> +$ ethtool -l eth0
> +Channel parameters for eth0:
> +Pre-set maximums:
> +RX: 8
> +TX: 8
> +Other: 0
> +Combined: 0
> +Current hardware settings:
> +RX: 1
> +TX: 5
> +Other: 0
> +Combined: 0
> +
> +3)
> +// TX queues must be rated starting from 0, so set bws for tx0 and tx1
> +// Set rates 40 and 20 Mb/s appropriately.
> +// Pay attention, real speed can differ a bit due to discreetness.
> +// Leave last 2 tx queues not rated.
> +$ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate
> +$ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate
> +
> +4)
> +// Check maximum rate of tx (cpdma) queues:
> +$ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate
> +40
> +20
> +0
> +0
> +0
> +
> +5)
> +// Map skb->priority to traffic class:
> +// 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
> +// Map traffic class to transmit queue:
> +// tc0 -> txq0, tc1 -> txq1, tc2 -> (txq2, txq3)
> +$ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
> +map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 1
> +
> +5a)
> +// As two interface sharing same set of tx queues, assign all traffic
> +// coming to interface Eth1 to separate queue in order to not mix it
> +// with traffic from interface Eth0, so use separate txq to send
> +// packets to Eth1, so all prio -> tc0 and tc0 -> txq4
> +// Here hw 0, so here still default configuration for eth1 in hw
> +$ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 1 \
> +map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 queues 1@4 hw 0
> +
> +6)
> +// Check classes settings
> +$ tc -g class show dev eth0
> ++---(100:ffe2) mqprio
> +| +---(100:3) mqprio
> +| +---(100:4) mqprio
> +|
> ++---(100:ffe1) mqprio
> +| +---(100:2) mqprio
> +|
> ++---(100:ffe0) mqprio
> + +---(100:1) mqprio
> +
> +$ tc -g class show dev eth1
> ++---(100:ffe0) mqprio
> + +---(100:5) mqprio
> +
> +7)
> +// Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc
> +// Set it +1 Mb for reserve (important!)
> +// here only idle slope is important, others arg are ignored
> +// Pay attention, real speed can differ a bit due to discreetness
> +$ tc qdisc add dev eth0 parent 100:1 cbs locredit -1438 \
> +hicredit 62 sendslope -959000 idleslope 41000 offload 1
> +net eth0: set FIFO3 bw = 50
> +
> +8)
> +// Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc:
> +// Set it +1 Mb for reserve (important!)
> +$ tc qdisc add dev eth0 parent 100:2 cbs locredit -1468 \
> +hicredit 65 sendslope -979000 idleslope 21000 offload 1
> +net eth0: set FIFO2 bw = 30
> +
> +9)
> +// Create vlan 100 to map sk->priority to vlan qos
> +$ ip link add link eth0 name eth0.100 type vlan id 100
> +8021q: 802.1Q VLAN Support v1.8
> +8021q: adding VLAN 0 to HW filter on device eth0
> +8021q: adding VLAN 0 to HW filter on device eth1
> +net eth0: Adding vlanid 100 to vlan filter
> +
> +10)
> +// Map skb->priority to L2 prio, 1 to 1
> +$ ip link set eth0.100 type vlan \
> +egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
> +
> +11)
> +// Check egress map for vlan 100
> +$ cat /proc/net/vlan/eth0.100
> +[...]
> +INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
> +EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
> +
> +12)
> +// Run your appropriate tools with socket option "SO_PRIORITY"
> +// to 3 for class A and/or to 2 for class B
> +// (I took at https://www.spinics.net/lists/netdev/msg460869.html)
> +./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500&
> +./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500&
> +
> +13)
> +// run your listener on workstation (should be in same vlan)
> +// (I took at https://www.spinics.net/lists/netdev/msg460869.html)
> +./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39000 kbps
> +
> +14)
> +// Restore default configuration if needed
> +$ ip link del eth0.100
> +$ tc qdisc del dev eth1 root
> +$ tc qdisc del dev eth0 root
> +net eth0: Prev FIFO2 is shaped
> +net eth0: set FIFO3 bw = 0
> +net eth0: set FIFO2 bw = 0
> +$ ethtool -L eth0 rx 1 tx 1
> +
> +*********************************************************************
> +*********************************************************************
> +*********************************************************************
> +Example 2: Two port tx AVB configuration scheme for target board
> +----------------------------------------------------------------------
> +(prints and scheme for AM52xx evm, for dual emac boards only)
> +
> ++------------------------------------------------------------------+ u
> +| +----------+ +----------+ +------+ +----------+ +----------+ | s
> +| | | | | | | | | | | | e
> +| | App 1 | | App 2 | | Apps | | App 3 | | App 4 | | r
> +| | Class A | | Class B | | Rest | | Class B | | Class A | |
> +| | Eth0 | | Eth0 | | | | | Eth1 | | Eth1 | | s
> +| | VLAN100 | | VLAN100 | | | | | VLAN100 | | VLAN100 | | p
> +| | 40 Mb/s | | 20 Mb/s | | | | | 10 Mb/s | | 30 Mb/s | | a
> +| | SO_PRI=3 | | SO_PRI=2 | | | | | SO_PRI=3 | | SO_PRI=2 | | c
> +| | | | | | | | | | | | | | | | | e
> +| +---|------+ +---|------+ +---|--+ +---|------+ +---|------+ |
> ++-----|-------------|-------------|---------|-------------|--------+
> + +-+ +-------+ | +----------+ +----+
> + | | +-------+------+ | |
> + | | | | | |
> ++---|-------|-------------|--------------|-------------|-------|---+
> +| +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ |
> +| | p3 | | p2 | | p1 | | p0 | | p0 | | p1 | | p2 | | p3 | | k
> +| \ / \ / \ / \ / \ / \ / \ / \ / | e
> +| \ / \ / \ / \ / \ / \ / \ / \ / | r
> +| \/ \/ \/ \/ \/ \/ \/ \/ | n
> +| | | | | | | | e
> +| | | +----+ +----+ | | | l
> +| | | | | | | |
> +| +----+ +----+ +----+ +----+ +----+ +----+ | s
> +| |tc0 | |tc1 | |tc2 | |tc2 | |tc1 | |tc0 | | p
> +| \ / \ / \ / \ / \ / \ / | a
> +| \ / \ / \ / \ / \ / \ / | c
> +| \/ \/ \/ \/ \/ \/ | e
> +| | | +-----+ +-----+ | | |
> +| | | | | | | | | |
> +| | | | | | | | | |
> +| | | | | E E | | | | |
> +| +----+ +----+ +----+ +----+ t t +----+ +----+ +----+ +----+ |
> +| |txq0| |txq1| |txq4| |txq5| h h |txq6| |txq7| |txq3| |txq2| |
> +| \ / \ / \ / \ / 0 1 \ / \ / \ / \ / |
> +| \ / \ / \ / \ / . . \ / \ / \ / \ / |
> +| \/ \/ \/ \/ 1 1 \/ \/ \/ \/ |
> +| +-|------|------|------|--+ 0 0 +-|------|------|------|--+ |
> +| | | | | | | 0 0 | | | | | | |
> ++---|------|------|------|---------------|------|------|------|----+
> + | | | | | | | |
> + p p p p p p p p
> + 3 2 0-1, 4-7 <-L2 pri-> 0-1, 4-7 2 3
> + | | | | | | | |
> + | | | | | | | |
> ++---|------|------|------|---------------|------|------|------|----+
> +| | | | | | | | | |
> +| +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ |
> +| |dma7| |dma6| |dma3| |dma2| |dma1| |dma0| |dma4| |dma5| |
> +| \ / \ / \ / \ / \ / \ / \ / \ / | c
> +| \S / \S / \ / \ / \ / \ / \S / \S / | p
> +| \/ \/ \/ \/ \/ \/ \/ \/ | s
> +| | | | +----- | | | | | w
> +| | | | | +----+ | | | |
> +| | | | | | | | | | d
> +| +----+ +----+ +----+p p+----+ +----+ +----+ | r
> +| | | | | | |o o| | | | | | | i
> +| | f3 | | f2 | | f0 |r CPSW r| f3 | | f2 | | f0 | | v
> +| |tc0 | |tc1 | |tc2 |t t|tc0 | |tc1 | |tc2 | | e
> +| \CBS / \CBS / \CBS /1 2\CBS / \CBS / \CBS / | r
> +| \S / \S / \ / \S / \S / \ / |
> +| \/ \/ \/ \/ \/ \/ |
> ++------------------------------------------------------------------+
> +========================================Eth==========================>
> +
> +1)
> +// Add 8 tx queues, for interface Eth0, but they are common, so are accessed
> +// by two interfaces Eth0 and Eth1.
> +$ ethtool -L eth1 rx 1 tx 8
> +rx unmodified, ignoring
> +
> +2)
> +// Check if num of queues is set correctly:
> +$ ethtool -l eth0
> +Channel parameters for eth0:
> +Pre-set maximums:
> +RX: 8
> +TX: 8
> +Other: 0
> +Combined: 0
> +Current hardware settings:
> +RX: 1
> +TX: 8
> +Other: 0
> +Combined: 0
> +
> +3)
> +// TX queues must be rated starting from 0, so set bws for tx0 and tx1 for Eth0
> +// and for tx2 and tx3 for Eth1. That is, rates 40 and 20 Mb/s appropriately
> +// for Eth0 and 30 and 10 Mb/s for Eth1.
> +// Real speed can differ a bit due to discreetness
> +// Leave last 4 tx queues as not rated
> +$ echo 40 > /sys/class/net/eth0/queues/tx-0/tx_maxrate
> +$ echo 20 > /sys/class/net/eth0/queues/tx-1/tx_maxrate
> +$ echo 30 > /sys/class/net/eth1/queues/tx-2/tx_maxrate
> +$ echo 10 > /sys/class/net/eth1/queues/tx-3/tx_maxrate
> +
> +4)
> +// Check maximum rate of tx (cpdma) queues:
> +$ cat /sys/class/net/eth0/queues/tx-*/tx_maxrate
> +40
> +20
> +30
> +10
> +0
> +0
> +0
> +0
> +
> +5)
> +// Map skb->priority to traffic class for Eth0:
> +// 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
> +// Map traffic class to transmit queue:
> +// tc0 -> txq0, tc1 -> txq1, tc2 -> (txq4, txq5)
> +$ tc qdisc replace dev eth0 handle 100: parent root mqprio num_tc 3 \
> +map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@4 hw 1
> +
> +6)
> +// Check classes settings
> +$ tc -g class show dev eth0
> ++---(100:ffe2) mqprio
> +| +---(100:5) mqprio
> +| +---(100:6) mqprio
> +|
> ++---(100:ffe1) mqprio
> +| +---(100:2) mqprio
> +|
> ++---(100:ffe0) mqprio
> + +---(100:1) mqprio
> +
> +7)
> +// Set rate for class A - 41 Mbit (tc0, txq0) using CBS Qdisc for Eth0
> +// here only idle slope is important, others ignored
> +// Real speed can differ a bit due to discreetness
> +$ tc qdisc add dev eth0 parent 100:1 cbs locredit -1470 \
> +hicredit 62 sendslope -959000 idleslope 41000 offload 1
> +net eth0: set FIFO3 bw = 50
> +
> +8)
> +// Set rate for class B - 21 Mbit (tc1, txq1) using CBS Qdisc for Eth0
> +$ tc qdisc add dev eth0 parent 100:2 cbs locredit -1470 \
> +hicredit 65 sendslope -979000 idleslope 21000 offload 1
> +net eth0: set FIFO2 bw = 30
> +
> +9)
> +// Create vlan 100 to map sk->priority to vlan qos for Eth0
> +$ ip link add link eth0 name eth0.100 type vlan id 100
> +net eth0: Adding vlanid 100 to vlan filter
> +
> +10)
> +// Map skb->priority to L2 prio for Eth0.100, one to one
> +$ ip link set eth0.100 type vlan \
> +egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
> +
> +11)
> +// Check egress map for vlan 100
> +$ cat /proc/net/vlan/eth0.100
> +[...]
> +INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
> +EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
> +
> +12)
> +// Map skb->priority to traffic class for Eth1:
> +// 3pri -> tc0, 2pri -> tc1, (0,1,4-7)pri -> tc2
> +// Map traffic class to transmit queue:
> +// tc0 -> txq2, tc1 -> txq3, tc2 -> (txq6, txq7)
> +$ tc qdisc replace dev eth1 handle 100: parent root mqprio num_tc 3 \
> +map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@2 1@3 2@6 hw 1
> +
> +13)
> +// Check classes settings
> +$ tc -g class show dev eth1
> ++---(100:ffe2) mqprio
> +| +---(100:7) mqprio
> +| +---(100:8) mqprio
> +|
> ++---(100:ffe1) mqprio
> +| +---(100:4) mqprio
> +|
> ++---(100:ffe0) mqprio
> + +---(100:3) mqprio
> +
> +14)
> +// Set rate for class A - 31 Mbit (tc0, txq2) using CBS Qdisc for Eth1
> +// here only idle slope is important, others ignored
> +// Set it +1 Mb for reserve (important!)
> +$ tc qdisc add dev eth1 parent 100:3 cbs locredit -1453 \
> +hicredit 47 sendslope -969000 idleslope 31000 offload 1
> +net eth1: set FIFO3 bw = 31
> +
> +15)
> +// Set rate for class B - 11 Mbit (tc1, txq3) using CBS Qdisc for Eth1
> +// Set it +1 Mb for reserve (important!)
> +$ tc qdisc add dev eth1 parent 100:4 cbs locredit -1483 \
> +hicredit 34 sendslope -989000 idleslope 11000 offload 1
> +net eth1: set FIFO2 bw = 11
> +
> +16)
> +// Create vlan 100 to map sk->priority to vlan qos for Eth1
> +$ ip link add link eth1 name eth1.100 type vlan id 100
> +net eth1: Adding vlanid 100 to vlan filter
> +
> +17)
> +// Map skb->priority to L2 prio for Eth1.100, one to one
> +$ ip link set eth1.100 type vlan \
> +egress 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
> +
> +18)
> +// Check egress map for vlan 100
> +$ cat /proc/net/vlan/eth1.100
> +[...]
> +INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0
> +EGRESS priority mappings: 0:0 1:1 2:2 3:3 4:4 5:5 6:6 7:7
> +
> +19)
> +// Run appropriate tools with socket option "SO_PRIORITY" to 3
> +// for class A and to 2 for class B. For both interfaces
> +./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p2 -s 1500&
> +./tsn_talker -d 18:03:73:66:87:42 -i eth0.100 -p3 -s 1500&
> +./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p2 -s 1500&
> +./tsn_talker -d 20:cf:30:85:7d:fd -i eth1.100 -p3 -s 1500&
> +
> +20)
> +// run your listener on workstation (should be in same vlan)
> +// (I took at https://www.spinics.net/lists/netdev/msg460869.html)
> +./tsn_listener -d 18:03:73:66:87:42 -i enp5s0 -s 1500
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39012 kbps
> +Receiving data rate: 39000 kbps
> +
> +21)
> +// Restore default configuration if needed
> +$ ip link del eth1.100
> +$ ip link del eth0.100
> +$ tc qdisc del dev eth1 root
> +net eth1: Prev FIFO2 is shaped
> +net eth1: set FIFO3 bw = 0
> +net eth1: set FIFO2 bw = 0
> +$ tc qdisc del dev eth0 root
> +net eth0: Prev FIFO2 is shaped
> +net eth0: set FIFO3 bw = 0
> +net eth0: set FIFO2 bw = 0
> +$ ethtool -L eth0 rx 1 tx 1
> --
> 2.17.1
>
^ permalink raw reply
* Re: [RFC PATCH ghak90 (was ghak32) V3 08/10] audit: NETFILTER_PKT: record each container ID associated with a netNS
From: Laura Garcia @ 2018-07-21 15:32 UTC (permalink / raw)
To: Richard Guy Briggs
Cc: cgroups, containers, linux-api, Linux-Audit Mailing List,
linux-fsdevel, LKML, netdev, luto, jlayton, carlos, viro,
dhowells, simo, eparis, serge, ebiederm,
Netfilter Development Mailing list
In-Reply-To: <c6b64f6540e2e531636142ced36d51f0744d0e1f.1528304204.git.rgb@redhat.com>
CC'ing Netfilter.
On Wed, Jun 6, 2018 at 6:58 PM, Richard Guy Briggs <rgb@redhat.com> wrote:
> Add audit container identifier auxiliary record(s) to NETFILTER_PKT
> event standalone records. Iterate through all potential audit container
> identifiers associated with a network namespace.
>
> Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
> ---
> include/linux/audit.h | 5 +++++
> kernel/audit.c | 20 +++++++++++++++++++-
> kernel/auditsc.c | 2 ++
> net/netfilter/xt_AUDIT.c | 12 ++++++++++--
> 4 files changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/audit.h b/include/linux/audit.h
> index 7e2e51c..4560a4e 100644
> --- a/include/linux/audit.h
> +++ b/include/linux/audit.h
> @@ -167,6 +167,8 @@ extern int audit_log_contid(struct audit_context *context,
> extern void audit_contid_add(struct net *net, u64 contid);
> extern void audit_contid_del(struct net *net, u64 contid);
> extern void audit_switch_task_namespaces(struct nsproxy *ns, struct task_struct *p);
> +extern void audit_log_contid_list(struct net *net,
> + struct audit_context *context);
>
> extern int audit_update_lsm_rules(void);
>
> @@ -231,6 +233,9 @@ static inline void audit_contid_del(struct net *net, u64 contid)
> { }
> static inline void audit_switch_task_namespaces(struct nsproxy *ns, struct task_struct *p)
> { }
> +static inline void audit_log_contid_list(struct net *net,
> + struct audit_context *context)
> +{ }
>
> #define audit_enabled 0
> #endif /* CONFIG_AUDIT */
> diff --git a/kernel/audit.c b/kernel/audit.c
> index ecd2de4..8cca41a 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -382,6 +382,20 @@ void audit_switch_task_namespaces(struct nsproxy *ns, struct task_struct *p)
> audit_contid_add(new->net_ns, contid);
> }
>
> +void audit_log_contid_list(struct net *net, struct audit_context *context)
> +{
> + struct audit_contid *cont;
> + int i = 0;
> +
> + list_for_each_entry(cont, audit_get_contid_list(net), list) {
> + char buf[14];
> +
> + sprintf(buf, "net%u", i++);
> + audit_log_contid(context, buf, cont->id);
> + }
> +}
> +EXPORT_SYMBOL(audit_log_contid_list);
> +
> void audit_panic(const char *message)
> {
> switch (audit_failure) {
> @@ -2132,17 +2146,21 @@ int audit_log_contid(struct audit_context *context,
> char *op, u64 contid)
> {
> struct audit_buffer *ab;
> + gfp_t gfpflags;
>
> if (!cid_valid(contid))
> return 0;
> + /* We can be called in atomic context via audit_tg() */
> + gfpflags = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
> /* Generate AUDIT_CONTAINER record with container ID */
> - ab = audit_log_start(context, GFP_KERNEL, AUDIT_CONTAINER);
> + ab = audit_log_start(context, gfpflags, AUDIT_CONTAINER);
> if (!ab)
> return -ENOMEM;
> audit_log_format(ab, "op=%s contid=%llu", op, contid);
> audit_log_end(ab);
> return 0;
> }
> +EXPORT_SYMBOL(audit_log_contid);
>
> void audit_log_key(struct audit_buffer *ab, char *key)
> {
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 6ab5e5e..e2a16d2 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1015,6 +1015,7 @@ struct audit_context *audit_alloc_local(void)
> context->in_syscall = 1;
> return context;
> }
> +EXPORT_SYMBOL(audit_alloc_local);
>
> void audit_free_context(struct audit_context *context)
> {
> @@ -1029,6 +1030,7 @@ void audit_free_context(struct audit_context *context)
> audit_proctitle_free(context);
> kfree(context);
> }
> +EXPORT_SYMBOL(audit_free_context);
>
> static int audit_log_pid_context(struct audit_context *context, pid_t pid,
> kuid_t auid, kuid_t uid, unsigned int sessionid,
> diff --git a/net/netfilter/xt_AUDIT.c b/net/netfilter/xt_AUDIT.c
> index f368ee6..10d2707 100644
> --- a/net/netfilter/xt_AUDIT.c
> +++ b/net/netfilter/xt_AUDIT.c
> @@ -71,10 +71,13 @@ static bool audit_ip6(struct audit_buffer *ab, struct sk_buff *skb)
> {
> struct audit_buffer *ab;
> int fam = -1;
> + struct audit_context *context;
> + struct net *net;
>
> if (audit_enabled == 0)
> - goto errout;
> - ab = audit_log_start(NULL, GFP_ATOMIC, AUDIT_NETFILTER_PKT);
> + goto out;
> + context = audit_alloc_local();
> + ab = audit_log_start(context, GFP_ATOMIC, AUDIT_NETFILTER_PKT);
> if (ab == NULL)
> goto errout;
>
> @@ -104,7 +107,12 @@ static bool audit_ip6(struct audit_buffer *ab, struct sk_buff *skb)
>
> audit_log_end(ab);
>
> + net = xt_net(par);
> + audit_log_contid_list(net, context);
> +
> errout:
> + audit_free_context(context);
> +out:
> return XT_CONTINUE;
> }
>
> --
> 1.8.3.1
>
^ permalink raw reply
* Re: [PATCH v4 net-next 0/6] net: ethernet: ti: cpsw: add MQPRIO and CBS Qdisc offload
From: David Miller @ 2018-07-21 15:34 UTC (permalink / raw)
To: ivan.khoronzhuk
Cc: grygorii.strashko, corbet, akpm, netdev, linux-doc, linux-kernel,
linux-omap, vinicius.gomes, henrik, jesus.sanchez-palencia,
ilias.apalodimas, p-varis, spatton, francois.ozog, yogeshs,
nsekhar, andrew
In-Reply-To: <20180721115923.1389-1-ivan.khoronzhuk@linaro.org>
Please address the feedback you were give on patch #6, thank you.
^ permalink raw reply
* RE: MY NAME IS MRS BELLA YOSTIN MOHAMMAD
From: Mrs Bella Yostin Mohammad @ 2018-07-21 15:44 UTC (permalink / raw)
Hello Dear.
My Name is Mrs. Bella Yostin Mohammad, I got your contact from a
business directory search and I decided to contact you directly. well
am originally from South Africa, but based in London, i am searching
for a reliable and honest and understanding person to go into
partnership in investing or to guide me in setting up a lucrative
business in the Middle east countries or the Arab countries,UAE or
OMAN and Kuwait, my plan is for my Son to fly to your country to meet
with you for the discussion and process of the investment.
So am only soliciting for your guidance for partnership or to help me
in investing in any lucrative business if you are interested.
My Idea of business is to invest into Tourism business or Medical
business or Real Estates business, this is my plan and i will be happy
if you will help in explaining more of either of this business which
is better for me to invest into in your country.all i want is to
invest into a good business that will bring higher profit.
like i explained above my plan is to send my Son down to meet with you
so both of you will meet face to face and discuss more so we will know
how to go about the process for the investment..
If you are willing to assist you will never regret assisting i and my son.
mean why if you are interested reply back to me with your mobile
number so that you and my son can discuss more in details.
And also for my Son to make his arrangement to fly down to your
country to meet with you over discussing about the investment.
I look forward for your reply.
Thanks with regards
Mrs. Bella Yostin Mohammad
^ 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