* Re: [PATCH net 1/7] secure_seq: return the full 64-bit of the siphash
From: Eric Dumazet @ 2022-04-27 16:50 UTC (permalink / raw)
To: Willy Tarreau
Cc: kernel test robot, netdev, kbuild-all, Jakub Kicinski, Moshe Kol,
Yossi Gilad, Amit Klein, LKML, Jason A . Donenfeld
In-Reply-To: <20220427163554.GA3746@1wt.eu>
On Wed, Apr 27, 2022 at 9:35 AM Willy Tarreau <w@1wt.eu> wrote:
>
> On Wed, Apr 27, 2022 at 12:07:14PM +0200, Willy Tarreau wrote:
> > On Wed, Apr 27, 2022 at 05:56:41PM +0800, kernel test robot wrote:
> > > Hi Willy,
> > >
> > > I love your patch! Yet something to improve:
> > >
> > > [auto build test ERROR on net/master]
> > >
> > > url: https://github.com/intel-lab-lkp/linux/commits/Willy-Tarreau/insufficient-TCP-source-port-randomness/20220427-145651
> > > base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 71cffebf6358a7f5031f5b208bbdc1cb4db6e539
> > > config: i386-randconfig-r026-20220425 (https://download.01.org/0day-ci/archive/20220427/202204271705.VrWNPv7n-lkp@intel.com/config)
> > > compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
> > > reproduce (this is a W=1 build):
> > > # https://github.com/intel-lab-lkp/linux/commit/01b26e522b598adf346b809075880feab3dcdc08
> > > git remote add linux-review https://github.com/intel-lab-lkp/linux
> > > git fetch --no-tags linux-review Willy-Tarreau/insufficient-TCP-source-port-randomness/20220427-145651
> > > git checkout 01b26e522b598adf346b809075880feab3dcdc08
> > > # save the config file
> > > mkdir build_dir && cp config build_dir/.config
> > > make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
> > >
> > > If you fix the issue, kindly add following tag as appropriate
> > > Reported-by: kernel test robot <lkp@intel.com>
> > >
> > > All errors (new ones prefixed by >>):
> > >
> > > ld: net/ipv4/inet_hashtables.o: in function `__inet_hash_connect':
> > > >> inet_hashtables.c:(.text+0x187d): undefined reference to `__umoddi3'
> >
> > Argh! indeed, we spoke about using div_u64_rem() at the beginning and
> > that one vanished over time. Will respin it.
>
> I fixed it, built it for i386 and x86_64, tested it on x86_64 and confirmed
> that it still does what I need. The change is only this:
>
> - offset = (READ_ONCE(table_perturb[index]) + (port_offset >> 32)) % remaining;
> + div_u64_rem(READ_ONCE(table_perturb[index]) + (port_offset >> 32), remaining, &offset);
>
> I'll send a v2 series in a few hours if there are no more comments.
We really do not need 33 bits here.
I would suggest using a 32bit divide.
offset = READ_ONCE(table_perturb[index]) + (port_offset >> 32));
offset %= remaining;
^ permalink raw reply
* Re: [RFC patch net-next 2/3] net: dsa: ksz: remove duplicate ksz_cfg and ksz_port_cfg
From: Vladimir Oltean @ 2022-04-27 16:49 UTC (permalink / raw)
To: Arun Ramadoss
Cc: linux-kernel, netdev, Paolo Abeni, Jakub Kicinski,
David S. Miller, Florian Fainelli, Vivien Didelot, Andrew Lunn,
UNGLinuxDriver, Woojung Huh
In-Reply-To: <20220427162343.18092-3-arun.ramadoss@microchip.com>
On Wed, Apr 27, 2022 at 09:53:42PM +0530, Arun Ramadoss wrote:
> ksz8795.c and ksz9477.c has individual ksz_cfg and ksz_port_cfg
Plural (have).
> function, both are same. Hence moving it to ksz_common.c. And removed
Present tense (remove).
> the individual references.
>
Small hint for writing commit messages. You should describe the entire
change, and walk the reviewer through the thought process.
Here, something which you are not mentioning is that the chip-local
implementation for ksz_port_cfg() that ksz8795 and ksz9477 have uses the
PORT_CTRL_ADDR() macro. Whereas the newly added generic ksz_port_cfg()
uses dev->dev_ops->get_port_addr(). The transformation is safe because
both ksz8795 and ksz9477 provide a get_port_addr() implementation.
I didn't know that, so I had to check.
^ permalink raw reply
* [PATCH wpan-next 11/11] net: mac802154: Introduce a synchronous API for MLME commands
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
This is the slow path, we need to wait for each command to be processed
before continuing so let's introduce an helper which does the
transmission and blocks until it gets notified of its asynchronous
completion. This helper is going to be used when introducing scan
support.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
net/mac802154/ieee802154_i.h | 1 +
net/mac802154/tx.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index c87c7fa04435..8aa8d0dd9c41 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -125,6 +125,7 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb);
void ieee802154_xmit_sync_worker(struct work_struct *work);
int ieee802154_sync_and_hold_queue(struct ieee802154_local *local);
+int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb);
netdev_tx_t
ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
netdev_tx_t
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 5f94973b57e4..17244293c59a 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -143,6 +143,25 @@ int ieee802154_sync_and_hold_queue(struct ieee802154_local *local)
return ieee802154_sync_queue(local);
}
+int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb)
+{
+ bool queue_held = ieee802154_queue_is_held(local);
+ int ret;
+
+ if (!queue_held)
+ ieee802154_sync_and_hold_queue(local);
+
+ ieee802154_tx(local, skb);
+ ret = ieee802154_sync_queue(local);
+
+ if (!queue_held)
+ ieee802154_release_queue(local);
+
+ ieee802154_wake_queue(local);
+
+ return ret;
+}
+
static netdev_tx_t
ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb)
{
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 10/11] net: mac802154: Introduce a tx queue flushing mechanism
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
Right now we are able to stop a queue but we have no indication if a
transmission is ongoing or not.
Thanks to recent additions, we can track the number of ongoing
transmissions so we know if the last transmission is over. Adding on top
of it an internal wait queue also allows to be woken up asynchronously
when this happens. If, beforehands, we marked the queue to be held and
stopped it, we end up flushing and stopping the tx queue.
Thanks to this feature, we will soon be able to introduce a synchronous
transmit API.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
include/net/cfg802154.h | 1 +
net/ieee802154/core.c | 1 +
net/mac802154/cfg.c | 3 +--
net/mac802154/ieee802154_i.h | 1 +
net/mac802154/tx.c | 24 +++++++++++++++++++++++-
net/mac802154/util.c | 7 +++++--
6 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 043d8e4359e7..0d385a214da3 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -217,6 +217,7 @@ struct wpan_phy {
/* Transmission monitoring and control */
atomic_t ongoing_txs;
atomic_t hold_txs;
+ wait_queue_head_t sync_txq;
char priv[] __aligned(NETDEV_ALIGN);
};
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index de259b5170ab..0953cacafbff 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -129,6 +129,7 @@ wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size)
wpan_phy_net_set(&rdev->wpan_phy, &init_net);
init_waitqueue_head(&rdev->dev_wait);
+ init_waitqueue_head(&rdev->wpan_phy.sync_txq);
return &rdev->wpan_phy;
}
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 0540a2b014d2..c17e38bef425 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -46,8 +46,7 @@ static int ieee802154_suspend(struct wpan_phy *wpan_phy)
if (!local->open_count)
goto suspend;
- ieee802154_hold_queue(local);
- ieee802154_stop_queue(local);
+ ieee802154_sync_and_hold_queue(local);
synchronize_net();
/* stop hardware - this must stop RX */
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index c686a027555a..c87c7fa04435 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -124,6 +124,7 @@ extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb);
void ieee802154_xmit_sync_worker(struct work_struct *work);
+int ieee802154_sync_and_hold_queue(struct ieee802154_local *local);
netdev_tx_t
ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
netdev_tx_t
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 021dddfea542..5f94973b57e4 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -45,7 +45,8 @@ void ieee802154_xmit_sync_worker(struct work_struct *work)
/* Restart the netif queue on each sub_if_data object. */
ieee802154_wake_queue(local);
kfree_skb(skb);
- atomic_dec(&local->phy->ongoing_txs);
+ if (!atomic_dec_and_test(&local->phy->ongoing_txs))
+ wake_up(&local->phy->sync_txq);
netdev_dbg(dev, "transmission failed\n");
}
@@ -121,6 +122,27 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local)
return atomic_read(&local->phy->hold_txs);
}
+static int ieee802154_sync_queue(struct ieee802154_local *local)
+{
+ int ret;
+
+ ieee802154_hold_queue(local);
+ ieee802154_disable_queue(local);
+ wait_event(local->phy->sync_txq, !atomic_read(&local->phy->ongoing_txs));
+ ret = local->tx_result;
+ ieee802154_release_queue(local);
+ ieee802154_wake_queue(local);
+
+ return ret;
+}
+
+int ieee802154_sync_and_hold_queue(struct ieee802154_local *local)
+{
+ ieee802154_hold_queue(local);
+
+ return ieee802154_sync_queue(local);
+}
+
static netdev_tx_t
ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb)
{
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index 3e2b157b34b1..056f8c4e6bcd 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -120,7 +120,8 @@ void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
}
dev_consume_skb_any(skb);
- atomic_dec(&hw->phy->ongoing_txs);
+ if (!atomic_dec_and_test(&hw->phy->ongoing_txs))
+ wake_up(&hw->phy->sync_txq);
}
EXPORT_SYMBOL(ieee802154_xmit_complete);
@@ -132,7 +133,9 @@ void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
local->tx_result = reason;
ieee802154_wake_queue(local);
dev_kfree_skb_any(skb);
- atomic_dec(&hw->phy->ongoing_txs);
+
+ if (!atomic_dec_and_test(&hw->phy->ongoing_txs))
+ wake_up(&hw->phy->sync_txq);
}
EXPORT_SYMBOL(ieee802154_xmit_error);
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 09/11] net: mac802154: Introduce a helper to disable the queue
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
Sometimes calling the stop queue helper is not enough because it does
not hold any lock. In order to be safe and avoid racy situations when
trying to (soon) sync the Tx queue, for instance before sending an MLME
frame, let's now introduce an helper which actually hold the necessary
locks when doing so.
Suggested-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
net/mac802154/ieee802154_i.h | 12 ++++++++++++
net/mac802154/util.c | 15 +++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index cb61a4abaf37..c686a027555a 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -186,6 +186,18 @@ void ieee802154_stop_queue(struct ieee802154_local *local);
*/
bool ieee802154_queue_is_stopped(struct ieee802154_local *local);
+/**
+ * ieee802154_disable_queue - disable ieee802154 queue
+ * @local: main mac object
+ *
+ * When trying to sync the Tx queue, we cannot just stop the queue
+ * (which is basically a bit being set without proper lock handling)
+ * because it would be racy. We actually need to call netif_tx_disable()
+ * instead, which is done by this helper. Restarting the queue can
+ * however still be done with a regular wake call.
+ */
+void ieee802154_disable_queue(struct ieee802154_local *local);
+
/* MIB callbacks */
void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index cfd17a7db532..3e2b157b34b1 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -62,6 +62,21 @@ bool ieee802154_queue_is_stopped(struct ieee802154_local *local)
return stopped;
}
+void ieee802154_disable_queue(struct ieee802154_local *local)
+{
+ struct ieee802154_sub_if_data *sdata;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(sdata, &local->interfaces, list) {
+ if (!sdata->dev)
+ continue;
+
+ netif_tx_disable(sdata->dev);
+ }
+ rcu_read_unlock();
+}
+EXPORT_SYMBOL(ieee802154_disable_queue);
+
enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer)
{
struct ieee802154_local *local =
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 08/11] net: mac802154: Add a warning in the hot path
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
We should never start a transmission after the queue has been stopped.
But because it might work we don't kill the function here but rather
warn loudly the user that something is wrong.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
net/mac802154/ieee802154_i.h | 8 ++++++++
net/mac802154/tx.c | 2 ++
net/mac802154/util.c | 18 ++++++++++++++++++
3 files changed, 28 insertions(+)
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index b55fdefb0b34..cb61a4abaf37 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -178,6 +178,14 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local);
*/
void ieee802154_stop_queue(struct ieee802154_local *local);
+/**
+ * ieee802154_queue_is_stopped - check whether ieee802154 queue was stopped
+ * @local: main mac object
+ *
+ * Goes through all the interfaces and indicates if they are all stopped or not.
+ */
+bool ieee802154_queue_is_stopped(struct ieee802154_local *local);
+
/* MIB callbacks */
void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index a8a83f0167bf..021dddfea542 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -124,6 +124,8 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local)
static netdev_tx_t
ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb)
{
+ WARN_ON_ONCE(ieee802154_queue_is_stopped(local));
+
return ieee802154_tx(local, skb);
}
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index 847e0864b575..cfd17a7db532 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -44,6 +44,24 @@ void ieee802154_stop_queue(struct ieee802154_local *local)
rcu_read_unlock();
}
+bool ieee802154_queue_is_stopped(struct ieee802154_local *local)
+{
+ struct ieee802154_sub_if_data *sdata;
+ bool stopped = true;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(sdata, &local->interfaces, list) {
+ if (!sdata->dev)
+ continue;
+
+ if (!netif_queue_stopped(sdata->dev))
+ stopped = false;
+ }
+ rcu_read_unlock();
+
+ return stopped;
+}
+
enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer)
{
struct ieee802154_local *local =
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 07/11] net: mac802154: Create a hot tx path
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
Let's rename the current Tx path to show that this is the "hot" Tx
path. We will soon introduce a slower Tx path for MLME commands.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
net/mac802154/tx.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index d088aa8119e8..a8a83f0167bf 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -121,6 +121,12 @@ bool ieee802154_queue_is_held(struct ieee802154_local *local)
return atomic_read(&local->phy->hold_txs);
}
+static netdev_tx_t
+ieee802154_hot_tx(struct ieee802154_local *local, struct sk_buff *skb)
+{
+ return ieee802154_tx(local, skb);
+}
+
netdev_tx_t
ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
@@ -128,7 +134,7 @@ ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev)
skb->skb_iif = dev->ifindex;
- return ieee802154_tx(sdata->local, skb);
+ return ieee802154_hot_tx(sdata->local, skb);
}
netdev_tx_t
@@ -150,5 +156,5 @@ ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev)
skb->skb_iif = dev->ifindex;
- return ieee802154_tx(sdata->local, skb);
+ return ieee802154_hot_tx(sdata->local, skb);
}
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 06/11] net: mac802154: Hold the transmit queue when relevant
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
Let's create a hold_txs atomic variable and increment/decrement it when
relevant. Currently we can use it during a suspend. Very soon we will
also use this feature during scans.
When the variable is incremented, any further wake up call will be
skipped until the variable gets decremented back.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
include/net/cfg802154.h | 3 ++-
net/mac802154/cfg.c | 2 ++
net/mac802154/ieee802154_i.h | 24 ++++++++++++++++++++++++
net/mac802154/tx.c | 15 +++++++++++++++
net/mac802154/util.c | 3 +++
5 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 473ebcb9b155..043d8e4359e7 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -214,8 +214,9 @@ struct wpan_phy {
/* the network namespace this phy lives in currently */
possible_net_t _net;
- /* Transmission monitoring */
+ /* Transmission monitoring and control */
atomic_t ongoing_txs;
+ atomic_t hold_txs;
char priv[] __aligned(NETDEV_ALIGN);
};
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index dafe02548161..0540a2b014d2 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -46,6 +46,7 @@ static int ieee802154_suspend(struct wpan_phy *wpan_phy)
if (!local->open_count)
goto suspend;
+ ieee802154_hold_queue(local);
ieee802154_stop_queue(local);
synchronize_net();
@@ -72,6 +73,7 @@ static int ieee802154_resume(struct wpan_phy *wpan_phy)
return ret;
wake_up:
+ ieee802154_release_queue(local);
ieee802154_wake_queue(local);
local->suspended = false;
return 0;
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 3f59a291b481..b55fdefb0b34 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -142,6 +142,30 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
*/
void ieee802154_wake_queue(struct ieee802154_local *local);
+/**
+ * ieee802154_hold_queue - hold ieee802154 queue
+ * @local: main mac object
+ *
+ * Hold a queue, this queue cannot be woken up while this is active.
+ */
+void ieee802154_hold_queue(struct ieee802154_local *local);
+
+/**
+ * ieee802154_release_queue - release ieee802154 queue
+ * @local: main mac object
+ *
+ * Release a queue which is held. The queue can now be woken up.
+ */
+void ieee802154_release_queue(struct ieee802154_local *local);
+
+/**
+ * ieee802154_queue_is_held - checks whether the ieee802154 queue is held
+ * @local: main mac object
+ *
+ * Checks whether the queue is currently held.
+ */
+bool ieee802154_queue_is_held(struct ieee802154_local *local);
+
/**
* ieee802154_stop_queue - stop ieee802154 queue
* @local: main mac object
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 8c0bad7796ba..d088aa8119e8 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -106,6 +106,21 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
return NETDEV_TX_OK;
}
+void ieee802154_hold_queue(struct ieee802154_local *local)
+{
+ atomic_inc(&local->phy->hold_txs);
+}
+
+void ieee802154_release_queue(struct ieee802154_local *local)
+{
+ atomic_dec(&local->phy->hold_txs);
+}
+
+bool ieee802154_queue_is_held(struct ieee802154_local *local)
+{
+ return atomic_read(&local->phy->hold_txs);
+}
+
netdev_tx_t
ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index 4bcc9cd2eb9d..847e0864b575 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -17,6 +17,9 @@ void ieee802154_wake_queue(struct ieee802154_local *local)
{
struct ieee802154_sub_if_data *sdata;
+ if (ieee802154_queue_is_held(local))
+ return;
+
rcu_read_lock();
list_for_each_entry_rcu(sdata, &local->interfaces, list) {
if (!sdata->dev)
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 05/11] net: mac802154: Follow the count of ongoing transmissions
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
In order to create a synchronous API for MLME command purposes, we need
to be able to track the end of the ongoing transmissions. Let's
introduce an atomic variable which is incremented when a transmission
starts and decremented when relevant so that we know at any moment
whether there is an ongoing transmission.
The counter gets decremented in the following situations:
- The operation is asynchronous and there was a failure during the
offloading process.
- The operation is synchronous and the synchronous operation failed.
- The operation finished, either successfully or not.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
include/net/cfg802154.h | 3 +++
net/mac802154/tx.c | 3 +++
net/mac802154/util.c | 2 ++
3 files changed, 8 insertions(+)
diff --git a/include/net/cfg802154.h b/include/net/cfg802154.h
index 85f9e8417688..473ebcb9b155 100644
--- a/include/net/cfg802154.h
+++ b/include/net/cfg802154.h
@@ -214,6 +214,9 @@ struct wpan_phy {
/* the network namespace this phy lives in currently */
possible_net_t _net;
+ /* Transmission monitoring */
+ atomic_t ongoing_txs;
+
char priv[] __aligned(NETDEV_ALIGN);
};
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 6d559f96664d..8c0bad7796ba 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -45,6 +45,7 @@ void ieee802154_xmit_sync_worker(struct work_struct *work)
/* Restart the netif queue on each sub_if_data object. */
ieee802154_wake_queue(local);
kfree_skb(skb);
+ atomic_dec(&local->phy->ongoing_txs);
netdev_dbg(dev, "transmission failed\n");
}
@@ -75,6 +76,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
/* Stop the netif queue on each sub_if_data object. */
ieee802154_stop_queue(local);
+ atomic_inc(&local->phy->ongoing_txs);
/* Drivers should preferably implement the async callback. In some rare
* cases they only provide a sync callback which we will use as a
@@ -99,6 +101,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
return NETDEV_TX_OK;
err_tx:
+ atomic_dec(&local->phy->ongoing_txs);
kfree_skb(skb);
return NETDEV_TX_OK;
}
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index 6ded390f0132..4bcc9cd2eb9d 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -84,6 +84,7 @@ void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
}
dev_consume_skb_any(skb);
+ atomic_dec(&hw->phy->ongoing_txs);
}
EXPORT_SYMBOL(ieee802154_xmit_complete);
@@ -95,6 +96,7 @@ void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
local->tx_result = reason;
ieee802154_wake_queue(local);
dev_kfree_skb_any(skb);
+ atomic_dec(&hw->phy->ongoing_txs);
}
EXPORT_SYMBOL(ieee802154_xmit_error);
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 04/11] net: mac802154: Rename the main tx_work struct
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
This entry is dedicated to synchronous transmissions done by drivers
without async hook. Make this clearer that this is not a work that any
driver can use by at least prefixing it with "sync_". While at it, let's
enhance the comment explaining why we choose one or the other.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
net/mac802154/ieee802154_i.h | 2 +-
net/mac802154/main.c | 2 +-
net/mac802154/tx.c | 9 ++++++---
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index d27e9fe363b6..3f59a291b481 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -55,7 +55,7 @@ struct ieee802154_local {
struct sk_buff_head skb_queue;
struct sk_buff *tx_skb;
- struct work_struct tx_work;
+ struct work_struct sync_tx_work;
/* A negative Linux error code or a null/positive MLME error status */
int tx_result;
};
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 13c6b3cd0429..46258c6d430f 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -95,7 +95,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)
skb_queue_head_init(&local->skb_queue);
- INIT_WORK(&local->tx_work, ieee802154_xmit_sync_worker);
+ INIT_WORK(&local->sync_tx_work, ieee802154_xmit_sync_worker);
/* init supported flags with 802.15.4 default ranges */
phy->supported.max_minbe = 8;
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 0ebe39169309..6d559f96664d 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -25,7 +25,7 @@
void ieee802154_xmit_sync_worker(struct work_struct *work)
{
struct ieee802154_local *local =
- container_of(work, struct ieee802154_local, tx_work);
+ container_of(work, struct ieee802154_local, sync_tx_work);
struct sk_buff *skb = local->tx_skb;
struct net_device *dev = skb->dev;
int res;
@@ -76,7 +76,10 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
/* Stop the netif queue on each sub_if_data object. */
ieee802154_stop_queue(local);
- /* async is priority, otherwise sync is fallback */
+ /* Drivers should preferably implement the async callback. In some rare
+ * cases they only provide a sync callback which we will use as a
+ * fallback.
+ */
if (local->ops->xmit_async) {
unsigned int len = skb->len;
@@ -90,7 +93,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
dev->stats.tx_bytes += len;
} else {
local->tx_skb = skb;
- queue_work(local->workqueue, &local->tx_work);
+ queue_work(local->workqueue, &local->sync_tx_work);
}
return NETDEV_TX_OK;
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 03/11] net: mac802154: Rename the synchronous xmit worker
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
There are currently two driver hooks: one is synchronous, the other is
not. We cannot rely on driver implementations to provide a synchronous
API (which is related to the bus medium more than a wish to have a
synchronized implementation) so we are going to introduce a sync API
above any kind of driver transmit function. In order to clarify what
this worker is for (synchronous driver implementation), let's rename it
so that people don't get bothered by the fact that their driver does not
make use of the "xmit worker" which is a too generic name.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
net/mac802154/ieee802154_i.h | 2 +-
net/mac802154/main.c | 2 +-
net/mac802154/tx.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 6652445a1147..d27e9fe363b6 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -123,7 +123,7 @@ ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata)
extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb);
-void ieee802154_xmit_worker(struct work_struct *work);
+void ieee802154_xmit_sync_worker(struct work_struct *work);
netdev_tx_t
ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
netdev_tx_t
diff --git a/net/mac802154/main.c b/net/mac802154/main.c
index 5546ef86e231..13c6b3cd0429 100644
--- a/net/mac802154/main.c
+++ b/net/mac802154/main.c
@@ -95,7 +95,7 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)
skb_queue_head_init(&local->skb_queue);
- INIT_WORK(&local->tx_work, ieee802154_xmit_worker);
+ INIT_WORK(&local->tx_work, ieee802154_xmit_sync_worker);
/* init supported flags with 802.15.4 default ranges */
phy->supported.max_minbe = 8;
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index c5befaca5366..0ebe39169309 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -22,7 +22,7 @@
#include "ieee802154_i.h"
#include "driver-ops.h"
-void ieee802154_xmit_worker(struct work_struct *work)
+void ieee802154_xmit_sync_worker(struct work_struct *work)
{
struct ieee802154_local *local =
container_of(work, struct ieee802154_local, tx_work);
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 02/11] net: mac802154: Change the wake/stop queue prototypes
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
Currently the pointer returned by *_alloc_hw() is used for these
helpers, while actually all the callers have a *local pointer available
and anyway this local pointer is going to be derived inside both
helpers. We will soon add more helpers like these so let's change the
prototype right now to improve the harmony in this file.
There is no functional change.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
net/mac802154/cfg.c | 4 ++--
net/mac802154/ieee802154_i.h | 8 ++++----
net/mac802154/tx.c | 6 +++---
net/mac802154/util.c | 12 +++++-------
4 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/net/mac802154/cfg.c b/net/mac802154/cfg.c
index 1e4a9f74ed43..dafe02548161 100644
--- a/net/mac802154/cfg.c
+++ b/net/mac802154/cfg.c
@@ -46,7 +46,7 @@ static int ieee802154_suspend(struct wpan_phy *wpan_phy)
if (!local->open_count)
goto suspend;
- ieee802154_stop_queue(&local->hw);
+ ieee802154_stop_queue(local);
synchronize_net();
/* stop hardware - this must stop RX */
@@ -72,7 +72,7 @@ static int ieee802154_resume(struct wpan_phy *wpan_phy)
return ret;
wake_up:
- ieee802154_wake_queue(&local->hw);
+ ieee802154_wake_queue(local);
local->suspended = false;
return 0;
}
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 83f5ccd1ca0f..6652445a1147 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -132,7 +132,7 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
/**
* ieee802154_wake_queue - wake ieee802154 queue
- * @hw: pointer as obtained from ieee802154_alloc_hw().
+ * @local: main mac object
*
* Tranceivers usually have either one transmit framebuffer or one framebuffer
* for both transmitting and receiving. Hence, the core currently only handles
@@ -140,11 +140,11 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
* avoid new skb to come during the transmission. The queue then needs to be
* woken up after the operation.
*/
-void ieee802154_wake_queue(struct ieee802154_hw *hw);
+void ieee802154_wake_queue(struct ieee802154_local *local);
/**
* ieee802154_stop_queue - stop ieee802154 queue
- * @hw: pointer as obtained from ieee802154_alloc_hw().
+ * @local: main mac object
*
* Tranceivers usually have either one transmit framebuffer or one framebuffer
* for both transmitting and receiving. Hence, the core currently only handles
@@ -152,7 +152,7 @@ void ieee802154_wake_queue(struct ieee802154_hw *hw);
* stop giving us new skbs while we are busy with the transmitted one. The queue
* must then be stopped before transmitting.
*/
-void ieee802154_stop_queue(struct ieee802154_hw *hw);
+void ieee802154_stop_queue(struct ieee802154_local *local);
/* MIB callbacks */
void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index c829e4a75325..c5befaca5366 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -43,7 +43,7 @@ void ieee802154_xmit_worker(struct work_struct *work)
err_tx:
/* Restart the netif queue on each sub_if_data object. */
- ieee802154_wake_queue(&local->hw);
+ ieee802154_wake_queue(local);
kfree_skb(skb);
netdev_dbg(dev, "transmission failed\n");
}
@@ -74,7 +74,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
}
/* Stop the netif queue on each sub_if_data object. */
- ieee802154_stop_queue(&local->hw);
+ ieee802154_stop_queue(local);
/* async is priority, otherwise sync is fallback */
if (local->ops->xmit_async) {
@@ -82,7 +82,7 @@ ieee802154_tx(struct ieee802154_local *local, struct sk_buff *skb)
ret = drv_xmit_async(local, skb);
if (ret) {
- ieee802154_wake_queue(&local->hw);
+ ieee802154_wake_queue(local);
goto err_tx;
}
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index 15a46b56d85a..6ded390f0132 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -13,9 +13,8 @@
/* privid for wpan_phys to determine whether they belong to us or not */
const void *const mac802154_wpan_phy_privid = &mac802154_wpan_phy_privid;
-void ieee802154_wake_queue(struct ieee802154_hw *hw)
+void ieee802154_wake_queue(struct ieee802154_local *local)
{
- struct ieee802154_local *local = hw_to_local(hw);
struct ieee802154_sub_if_data *sdata;
rcu_read_lock();
@@ -28,9 +27,8 @@ void ieee802154_wake_queue(struct ieee802154_hw *hw)
rcu_read_unlock();
}
-void ieee802154_stop_queue(struct ieee802154_hw *hw)
+void ieee802154_stop_queue(struct ieee802154_local *local)
{
- struct ieee802154_local *local = hw_to_local(hw);
struct ieee802154_sub_if_data *sdata;
rcu_read_lock();
@@ -48,7 +46,7 @@ enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer)
struct ieee802154_local *local =
container_of(timer, struct ieee802154_local, ifs_timer);
- ieee802154_wake_queue(&local->hw);
+ ieee802154_wake_queue(local);
return HRTIMER_NORESTART;
}
@@ -82,7 +80,7 @@ void ieee802154_xmit_complete(struct ieee802154_hw *hw, struct sk_buff *skb,
hw->phy->sifs_period * NSEC_PER_USEC,
HRTIMER_MODE_REL);
} else {
- ieee802154_wake_queue(hw);
+ ieee802154_wake_queue(local);
}
dev_consume_skb_any(skb);
@@ -95,7 +93,7 @@ void ieee802154_xmit_error(struct ieee802154_hw *hw, struct sk_buff *skb,
struct ieee802154_local *local = hw_to_local(hw);
local->tx_result = reason;
- ieee802154_wake_queue(hw);
+ ieee802154_wake_queue(local);
dev_kfree_skb_any(skb);
}
EXPORT_SYMBOL(ieee802154_xmit_error);
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 01/11] net: mac802154: Stop exporting ieee802154_wake/stop_queue()
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
In-Reply-To: <20220427164659.106447-1-miquel.raynal@bootlin.com>
Individual drivers do not necessarily need to call these helpers
manually. There are other functions, more suited for this purpose, that
will do that for them. The advantage is that, as no more drivers call
these, it eases the tracking of the ongoing transfers that we are about
to introduce while keeping the possibility to bypass thse counters from
core code.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
include/net/mac802154.h | 27 ---------------------------
net/mac802154/ieee802154_i.h | 24 ++++++++++++++++++++++++
net/mac802154/util.c | 2 --
3 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index bdac0ddbdcdb..357d25ef627a 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -460,33 +460,6 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw);
*/
void ieee802154_rx_irqsafe(struct ieee802154_hw *hw, struct sk_buff *skb,
u8 lqi);
-/**
- * ieee802154_wake_queue - wake ieee802154 queue
- * @hw: pointer as obtained from ieee802154_alloc_hw().
- *
- * Tranceivers usually have either one transmit framebuffer or one framebuffer
- * for both transmitting and receiving. Hence, the core currently only handles
- * one frame at a time for each phy, which means we had to stop the queue to
- * avoid new skb to come during the transmission. The queue then needs to be
- * woken up after the operation.
- *
- * Drivers should use this function instead of netif_wake_queue.
- */
-void ieee802154_wake_queue(struct ieee802154_hw *hw);
-
-/**
- * ieee802154_stop_queue - stop ieee802154 queue
- * @hw: pointer as obtained from ieee802154_alloc_hw().
- *
- * Tranceivers usually have either one transmit framebuffer or one framebuffer
- * for both transmitting and receiving. Hence, the core currently only handles
- * one frame at a time for each phy, which means we need to tell upper layers to
- * stop giving us new skbs while we are busy with the transmitted one. The queue
- * must then be stopped before transmitting.
- *
- * Drivers should use this function instead of netif_stop_queue.
- */
-void ieee802154_stop_queue(struct ieee802154_hw *hw);
/**
* ieee802154_xmit_complete - frame transmission complete
diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h
index 1381e6a5e180..83f5ccd1ca0f 100644
--- a/net/mac802154/ieee802154_i.h
+++ b/net/mac802154/ieee802154_i.h
@@ -130,6 +130,30 @@ netdev_tx_t
ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
+/**
+ * ieee802154_wake_queue - wake ieee802154 queue
+ * @hw: pointer as obtained from ieee802154_alloc_hw().
+ *
+ * Tranceivers usually have either one transmit framebuffer or one framebuffer
+ * for both transmitting and receiving. Hence, the core currently only handles
+ * one frame at a time for each phy, which means we had to stop the queue to
+ * avoid new skb to come during the transmission. The queue then needs to be
+ * woken up after the operation.
+ */
+void ieee802154_wake_queue(struct ieee802154_hw *hw);
+
+/**
+ * ieee802154_stop_queue - stop ieee802154 queue
+ * @hw: pointer as obtained from ieee802154_alloc_hw().
+ *
+ * Tranceivers usually have either one transmit framebuffer or one framebuffer
+ * for both transmitting and receiving. Hence, the core currently only handles
+ * one frame at a time for each phy, which means we need to tell upper layers to
+ * stop giving us new skbs while we are busy with the transmitted one. The queue
+ * must then be stopped before transmitting.
+ */
+void ieee802154_stop_queue(struct ieee802154_hw *hw);
+
/* MIB callbacks */
void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
diff --git a/net/mac802154/util.c b/net/mac802154/util.c
index 9f024d85563b..15a46b56d85a 100644
--- a/net/mac802154/util.c
+++ b/net/mac802154/util.c
@@ -27,7 +27,6 @@ void ieee802154_wake_queue(struct ieee802154_hw *hw)
}
rcu_read_unlock();
}
-EXPORT_SYMBOL(ieee802154_wake_queue);
void ieee802154_stop_queue(struct ieee802154_hw *hw)
{
@@ -43,7 +42,6 @@ void ieee802154_stop_queue(struct ieee802154_hw *hw)
}
rcu_read_unlock();
}
-EXPORT_SYMBOL(ieee802154_stop_queue);
enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer)
{
--
2.27.0
^ permalink raw reply related
* [PATCH wpan-next 00/11] ieee802154: Synchronous Tx support
From: Miquel Raynal @ 2022-04-27 16:46 UTC (permalink / raw)
To: Alexander Aring, Stefan Schmidt, linux-wpan
Cc: David S. Miller, Jakub Kicinski, netdev, David Girault,
Romuald Despres, Frederic Blain, Nicolas Schodet,
Thomas Petazzoni, Miquel Raynal
Hello,
New series bringing support for that famous synchronous Tx API for MLME
commands.
MLME commands will be used for during scan operations.
We need to be able to be sure that all transfers finished and that no
transfer will be queued for a short moment.
Cheers,
Miquèl
Miquel Raynal (11):
net: mac802154: Stop exporting ieee802154_wake/stop_queue()
net: mac802154: Change the wake/stop queue prototypes
net: mac802154: Rename the synchronous xmit worker
net: mac802154: Rename the main tx_work struct
net: mac802154: Follow the count of ongoing transmissions
net: mac802154: Hold the transmit queue when relevant
net: mac802154: Create a hot tx path
net: mac802154: Add a warning in the hot path
net: mac802154: Introduce a helper to disable the queue
net: mac802154: Introduce a tx queue flushing mechanism
net: mac802154: Introduce a synchronous API for MLME commands
include/net/cfg802154.h | 5 ++
include/net/mac802154.h | 27 -----------
net/ieee802154/core.c | 1 +
net/mac802154/cfg.c | 5 +-
net/mac802154/ieee802154_i.h | 74 +++++++++++++++++++++++++++++-
net/mac802154/main.c | 2 +-
net/mac802154/tx.c | 88 ++++++++++++++++++++++++++++++++----
net/mac802154/util.c | 55 ++++++++++++++++++----
8 files changed, 207 insertions(+), 50 deletions(-)
--
2.27.0
^ permalink raw reply
* Re: [RFC patch net-next 1/3] net: dsa: ksz9477: port mirror sniffing limited to one port
From: Vladimir Oltean @ 2022-04-27 16:40 UTC (permalink / raw)
To: Arun Ramadoss
Cc: linux-kernel, netdev, Paolo Abeni, Jakub Kicinski,
David S. Miller, Florian Fainelli, Vivien Didelot, Andrew Lunn,
UNGLinuxDriver, Woojung Huh
In-Reply-To: <20220427162343.18092-2-arun.ramadoss@microchip.com>
On Wed, Apr 27, 2022 at 09:53:41PM +0530, Arun Ramadoss wrote:
> This patch limits the sniffing to only one port during the mirror add.
> And during the mirror_del it checks for all the ports using the sniff,
> if and only if no other ports are referring, sniffing is disabled.
> The code is updated based on the review comments of LAN937x port mirror
> patch.
> https://patchwork.kernel.org/project/netdevbpf/patch/20210422094257.1641396-8-prasanna.vengateshan@microchip.com/
>
> Signed-off-by: Prasanna Vengateshan <prasanna.vengateshan@microchip.com>
> Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
> ---
This probably needs:
Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
with the mention that it probably won't be backported too far due to the
dependency on 0148bb50b8fd ("net: dsa: pass extack to dsa_switch_ops ::
port_mirror_add()"). But this doesn't change what you should do.
You should send it towards the "net" tree (probably right now), wait
until the "net" pull request for this gets sent out, then "net" gets
merged back into "net-next", then you can continue your work with the
other patches.
> drivers/net/dsa/microchip/ksz9477.c | 38 ++++++++++++++++++++++++++---
> 1 file changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
> index 4f617fee9a4e..90ce789107eb 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c
> @@ -990,14 +990,32 @@ static int ksz9477_port_mirror_add(struct dsa_switch *ds, int port,
> bool ingress, struct netlink_ext_ack *extack)
> {
> struct ksz_device *dev = ds->priv;
> + u8 data;
> + int p;
> +
> + /* Limit to one sniffer port
> + * Check if any of the port is already set for sniffing
> + * If yes, instruct the user to remove the previous entry & exit
> + */
> + for (p = 0; p < dev->port_cnt; p++) {
> + /* Skip the current sniffing port */
> + if (p == mirror->to_local_port)
> + continue;
> +
> + ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
> +
> + if (data & PORT_MIRROR_SNIFFER) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Sniffer port is already configured, delete existing rules & retry");
> + return -EBUSY;
> + }
> + }
>
> if (ingress)
> ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, true);
> else
> ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, true);
>
> - ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_SNIFFER, false);
> -
> /* configure mirror port */
> ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
> PORT_MIRROR_SNIFFER, true);
> @@ -1011,16 +1029,28 @@ static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port,
> struct dsa_mall_mirror_tc_entry *mirror)
> {
> struct ksz_device *dev = ds->priv;
> + bool in_use = false;
> u8 data;
> + int p;
>
> if (mirror->ingress)
> ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, false);
> else
> ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, false);
>
> - ksz_pread8(dev, port, P_MIRROR_CTRL, &data);
>
> - if (!(data & (PORT_MIRROR_RX | PORT_MIRROR_TX)))
> + /* Check if any of the port is still referring to sniffer port */
> + for (p = 0; p < dev->port_cnt; p++) {
> + ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
> +
> + if ((data & (PORT_MIRROR_RX | PORT_MIRROR_TX))) {
> + in_use = true;
> + break;
> + }
> + }
> +
> + /* delete sniffing if there are no other mirroring rule exist */
Either "there are no other mirroring rules", or "no other mirroring rule
exists".
> + if (!in_use)
> ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
> PORT_MIRROR_SNIFFER, false);
> }
> --
> 2.33.0
>
^ permalink raw reply
* Re: [PATCH v2] MAINTAINERS: Update BNXT entry with firmware files
From: Michael Chan @ 2022-04-27 16:38 UTC (permalink / raw)
To: Florian Fainelli; +Cc: Netdev, Rafał Miłecki, andy
In-Reply-To: <20220427163606.126154-1-f.fainelli@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 469 bytes --]
On Wed, Apr 27, 2022 at 9:36 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> There appears to be a maintainer gap for BNXT TEE firmware files which
> causes some patches to be missed. Update the entry for the BNXT Ethernet
> controller with its companion firmware files.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> Changes in v2:
>
> - corrected header path (missing leading include/)
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
^ permalink raw reply
* [PATCH v2] MAINTAINERS: Update BNXT entry with firmware files
From: Florian Fainelli @ 2022-04-27 16:36 UTC (permalink / raw)
To: netdev; +Cc: michael.chan, zajec5, andy, Florian Fainelli
There appears to be a maintainer gap for BNXT TEE firmware files which
causes some patches to be missed. Update the entry for the BNXT Ethernet
controller with its companion firmware files.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- corrected header path (missing leading include/)
MAINTAINERS | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index f585242da63d..7a032c4126d5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3927,7 +3927,9 @@ BROADCOM BNXT_EN 50 GIGABIT ETHERNET DRIVER
M: Michael Chan <michael.chan@broadcom.com>
L: netdev@vger.kernel.org
S: Supported
+F: drivers/firmware/broadcom/tee_bnxt_fw.c
F: drivers/net/ethernet/broadcom/bnxt/
+F: include/linux/firmware/broadcom/tee_bnxt_fw.h
BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER
M: Arend van Spriel <aspriel@gmail.com>
--
2.25.1
^ permalink raw reply related
* Re: [PATCH net 1/7] secure_seq: return the full 64-bit of the siphash
From: Willy Tarreau @ 2022-04-27 16:35 UTC (permalink / raw)
To: kernel test robot
Cc: netdev, kbuild-all, Jakub Kicinski, Eric Dumazet, Moshe Kol,
Yossi Gilad, Amit Klein, linux-kernel, Jason A . Donenfeld
In-Reply-To: <20220427100714.GC1724@1wt.eu>
On Wed, Apr 27, 2022 at 12:07:14PM +0200, Willy Tarreau wrote:
> On Wed, Apr 27, 2022 at 05:56:41PM +0800, kernel test robot wrote:
> > Hi Willy,
> >
> > I love your patch! Yet something to improve:
> >
> > [auto build test ERROR on net/master]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Willy-Tarreau/insufficient-TCP-source-port-randomness/20220427-145651
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git 71cffebf6358a7f5031f5b208bbdc1cb4db6e539
> > config: i386-randconfig-r026-20220425 (https://download.01.org/0day-ci/archive/20220427/202204271705.VrWNPv7n-lkp@intel.com/config)
> > compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
> > reproduce (this is a W=1 build):
> > # https://github.com/intel-lab-lkp/linux/commit/01b26e522b598adf346b809075880feab3dcdc08
> > git remote add linux-review https://github.com/intel-lab-lkp/linux
> > git fetch --no-tags linux-review Willy-Tarreau/insufficient-TCP-source-port-randomness/20220427-145651
> > git checkout 01b26e522b598adf346b809075880feab3dcdc08
> > # save the config file
> > mkdir build_dir && cp config build_dir/.config
> > make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All errors (new ones prefixed by >>):
> >
> > ld: net/ipv4/inet_hashtables.o: in function `__inet_hash_connect':
> > >> inet_hashtables.c:(.text+0x187d): undefined reference to `__umoddi3'
>
> Argh! indeed, we spoke about using div_u64_rem() at the beginning and
> that one vanished over time. Will respin it.
I fixed it, built it for i386 and x86_64, tested it on x86_64 and confirmed
that it still does what I need. The change is only this:
- offset = (READ_ONCE(table_perturb[index]) + (port_offset >> 32)) % remaining;
+ div_u64_rem(READ_ONCE(table_perturb[index]) + (port_offset >> 32), remaining, &offset);
I'll send a v2 series in a few hours if there are no more comments.
Willy
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Update BNXT entry with firmware files
From: Michael Chan @ 2022-04-27 16:34 UTC (permalink / raw)
To: Florian Fainelli; +Cc: Netdev, Rafał Miłecki, andy
In-Reply-To: <5fa9f853-962e-784f-772c-7cbe61f38eec@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]
On Wed, Apr 27, 2022 at 9:32 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> On 4/27/22 09:29, Michael Chan wrote:
> > On Wed, Apr 27, 2022 at 9:21 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>
> >> There appears to be a maintainer gap for BNXT TEE firmware files which
> >> causes some patches to be missed. Update the entry for the BNXT Ethernet
> >> controller with its companion firmware files.
> >>
> >> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> >> ---
> >> MAINTAINERS | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
> >> diff --git a/MAINTAINERS b/MAINTAINERS
> >> index f585242da63d..0316d0c9a908 100644
> >> --- a/MAINTAINERS
> >> +++ b/MAINTAINERS
> >> @@ -3927,7 +3927,9 @@ BROADCOM BNXT_EN 50 GIGABIT ETHERNET DRIVER
> >> M: Michael Chan <michael.chan@broadcom.com>
> >> L: netdev@vger.kernel.org
> >> S: Supported
> >> +F: drivers/firmware/broadcom/tee_bnxt_fw.c
> >> F: drivers/net/ethernet/broadcom/bnxt/
> >> +F: linux/firmware/broadcom/tee_bnxt_fw.h
> >
> > should be include/linux/firmware/...
>
> Meh, I copy/pasted without adding it, thanks Michael, does that mean you
> are ok with being copied on those file changes?
Yes. Thanks.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Update BNXT entry with firmware files
From: Florian Fainelli @ 2022-04-27 16:32 UTC (permalink / raw)
To: Michael Chan; +Cc: Netdev, Rafał Miłecki, andy
In-Reply-To: <CACKFLi=Zg54Uaewkrn9J9wBT3-ucCCJbPu=yXc61PTs=SDkTkQ@mail.gmail.com>
On 4/27/22 09:29, Michael Chan wrote:
> On Wed, Apr 27, 2022 at 9:21 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>>
>> There appears to be a maintainer gap for BNXT TEE firmware files which
>> causes some patches to be missed. Update the entry for the BNXT Ethernet
>> controller with its companion firmware files.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>> MAINTAINERS | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index f585242da63d..0316d0c9a908 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -3927,7 +3927,9 @@ BROADCOM BNXT_EN 50 GIGABIT ETHERNET DRIVER
>> M: Michael Chan <michael.chan@broadcom.com>
>> L: netdev@vger.kernel.org
>> S: Supported
>> +F: drivers/firmware/broadcom/tee_bnxt_fw.c
>> F: drivers/net/ethernet/broadcom/bnxt/
>> +F: linux/firmware/broadcom/tee_bnxt_fw.h
>
> should be include/linux/firmware/...
Meh, I copy/pasted without adding it, thanks Michael, does that mean you
are ok with being copied on those file changes?
--
Florian
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Update BNXT entry with firmware files
From: Andy Shevchenko @ 2022-04-27 16:32 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, michael.chan, Rafał Miłecki, Andy Shevchenko
In-Reply-To: <20220427162145.121370-1-f.fainelli@gmail.com>
On Wed, Apr 27, 2022 at 6:21 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> There appears to be a maintainer gap for BNXT TEE firmware files which
> causes some patches to be missed. Update the entry for the BNXT Ethernet
> controller with its companion firmware files.
Thanks for adding this!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH] MAINTAINERS: Update BNXT entry with firmware files
From: Michael Chan @ 2022-04-27 16:29 UTC (permalink / raw)
To: Florian Fainelli; +Cc: Netdev, Rafał Miłecki, andy
In-Reply-To: <20220427162145.121370-1-f.fainelli@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 878 bytes --]
On Wed, Apr 27, 2022 at 9:21 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> There appears to be a maintainer gap for BNXT TEE firmware files which
> causes some patches to be missed. Update the entry for the BNXT Ethernet
> controller with its companion firmware files.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> MAINTAINERS | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f585242da63d..0316d0c9a908 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3927,7 +3927,9 @@ BROADCOM BNXT_EN 50 GIGABIT ETHERNET DRIVER
> M: Michael Chan <michael.chan@broadcom.com>
> L: netdev@vger.kernel.org
> S: Supported
> +F: drivers/firmware/broadcom/tee_bnxt_fw.c
> F: drivers/net/ethernet/broadcom/bnxt/
> +F: linux/firmware/broadcom/tee_bnxt_fw.h
should be include/linux/firmware/...
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
^ permalink raw reply
* [RFC patch net-next 2/3] net: dsa: ksz: remove duplicate ksz_cfg and ksz_port_cfg
From: Arun Ramadoss @ 2022-04-27 16:23 UTC (permalink / raw)
To: linux-kernel, netdev
Cc: Paolo Abeni, Jakub Kicinski, David S. Miller, Vladimir Oltean,
Florian Fainelli, Vivien Didelot, Andrew Lunn, UNGLinuxDriver,
Woojung Huh
In-Reply-To: <20220427162343.18092-1-arun.ramadoss@microchip.com>
ksz8795.c and ksz9477.c has individual ksz_cfg and ksz_port_cfg
function, both are same. Hence moving it to ksz_common.c. And removed
the individual references.
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
drivers/net/dsa/microchip/ksz8795.c | 12 ------------
drivers/net/dsa/microchip/ksz9477.c | 12 ------------
drivers/net/dsa/microchip/ksz_common.h | 13 +++++++++++++
3 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index f91deea9368e..33453060fa71 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -211,18 +211,6 @@ static bool ksz_is_ksz88x3(struct ksz_device *dev)
return dev->chip_id == 0x8830;
}
-static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
-{
- regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0);
-}
-
-static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
- bool set)
-{
- regmap_update_bits(dev->regmap[0], PORT_CTRL_ADDR(port, offset),
- bits, set ? bits : 0);
-}
-
static int ksz8_ind_write8(struct ksz_device *dev, u8 table, u16 addr, u8 data)
{
struct ksz8 *ksz8 = dev->priv;
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 90ce789107eb..f762120ce3fd 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -159,18 +159,6 @@ static void ksz9477_get_stats64(struct dsa_switch *ds, int port,
spin_unlock(&mib->stats64_lock);
}
-static void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
-{
- regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0);
-}
-
-static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
- bool set)
-{
- regmap_update_bits(dev->regmap[0], PORT_CTRL_ADDR(port, offset),
- bits, set ? bits : 0);
-}
-
static void ksz9477_cfg32(struct ksz_device *dev, u32 addr, u32 bits, bool set)
{
regmap_update_bits(dev->regmap[2], addr, bits, set ? bits : 0);
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 4d978832c448..4f049e9d8952 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -246,6 +246,11 @@ static inline int ksz_write64(struct ksz_device *dev, u32 reg, u64 value)
return regmap_bulk_write(dev->regmap[2], reg, val, 2);
}
+static inline void ksz_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set)
+{
+ regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0);
+}
+
static inline void ksz_pread8(struct ksz_device *dev, int port, int offset,
u8 *data)
{
@@ -282,6 +287,14 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset,
ksz_write32(dev, dev->dev_ops->get_port_addr(port, offset), data);
}
+static inline void ksz_port_cfg(struct ksz_device *dev, int port, int offset,
+ u8 bits, bool set)
+{
+ regmap_update_bits(dev->regmap[0],
+ dev->dev_ops->get_port_addr(port, offset),
+ bits, set ? bits : 0);
+}
+
static inline void ksz_regmap_lock(void *__mtx)
{
struct mutex *mtx = __mtx;
--
2.33.0
^ permalink raw reply related
* [RFC patch net-next 3/3] net: dsa: ksz: moved ksz9477 port mirror to ksz_common.c
From: Arun Ramadoss @ 2022-04-27 16:23 UTC (permalink / raw)
To: linux-kernel, netdev
Cc: Paolo Abeni, Jakub Kicinski, David S. Miller, Vladimir Oltean,
Florian Fainelli, Vivien Didelot, Andrew Lunn, UNGLinuxDriver,
Woojung Huh
In-Reply-To: <20220427162343.18092-1-arun.ramadoss@microchip.com>
Moved the port_mirror_add and port_mirror_del function from ksz9477 to
ksz_common, to make it generic function which can be used by KSZ9477
based switch.
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
drivers/net/dsa/microchip/ksz9477.c | 74 +------------------------
drivers/net/dsa/microchip/ksz9477_reg.h | 15 -----
drivers/net/dsa/microchip/ksz_common.c | 72 ++++++++++++++++++++++++
drivers/net/dsa/microchip/ksz_common.h | 5 ++
drivers/net/dsa/microchip/ksz_reg.h | 29 ++++++++++
5 files changed, 108 insertions(+), 87 deletions(-)
create mode 100644 drivers/net/dsa/microchip/ksz_reg.h
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index f762120ce3fd..d568ebfaf8c1 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -973,76 +973,6 @@ static int ksz9477_port_mdb_del(struct dsa_switch *ds, int port,
return ret;
}
-static int ksz9477_port_mirror_add(struct dsa_switch *ds, int port,
- struct dsa_mall_mirror_tc_entry *mirror,
- bool ingress, struct netlink_ext_ack *extack)
-{
- struct ksz_device *dev = ds->priv;
- u8 data;
- int p;
-
- /* Limit to one sniffer port
- * Check if any of the port is already set for sniffing
- * If yes, instruct the user to remove the previous entry & exit
- */
- for (p = 0; p < dev->port_cnt; p++) {
- /* Skip the current sniffing port */
- if (p == mirror->to_local_port)
- continue;
-
- ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
-
- if (data & PORT_MIRROR_SNIFFER) {
- NL_SET_ERR_MSG_MOD(extack,
- "Sniffer port is already configured, delete existing rules & retry");
- return -EBUSY;
- }
- }
-
- if (ingress)
- ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, true);
- else
- ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, true);
-
- /* configure mirror port */
- ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
- PORT_MIRROR_SNIFFER, true);
-
- ksz_cfg(dev, S_MIRROR_CTRL, SW_MIRROR_RX_TX, false);
-
- return 0;
-}
-
-static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port,
- struct dsa_mall_mirror_tc_entry *mirror)
-{
- struct ksz_device *dev = ds->priv;
- bool in_use = false;
- u8 data;
- int p;
-
- if (mirror->ingress)
- ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, false);
- else
- ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, false);
-
-
- /* Check if any of the port is still referring to sniffer port */
- for (p = 0; p < dev->port_cnt; p++) {
- ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
-
- if ((data & (PORT_MIRROR_RX | PORT_MIRROR_TX))) {
- in_use = true;
- break;
- }
- }
-
- /* delete sniffing if there are no other mirroring rule exist */
- if (!in_use)
- ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
- PORT_MIRROR_SNIFFER, false);
-}
-
static bool ksz9477_get_gbit(struct ksz_device *dev, u8 data)
{
bool gbit;
@@ -1478,8 +1408,8 @@ static const struct dsa_switch_ops ksz9477_switch_ops = {
.port_fdb_del = ksz9477_port_fdb_del,
.port_mdb_add = ksz9477_port_mdb_add,
.port_mdb_del = ksz9477_port_mdb_del,
- .port_mirror_add = ksz9477_port_mirror_add,
- .port_mirror_del = ksz9477_port_mirror_del,
+ .port_mirror_add = ksz_port_mirror_add,
+ .port_mirror_del = ksz_port_mirror_del,
.get_stats64 = ksz9477_get_stats64,
.port_change_mtu = ksz9477_change_mtu,
.port_max_mtu = ksz9477_max_mtu,
diff --git a/drivers/net/dsa/microchip/ksz9477_reg.h b/drivers/net/dsa/microchip/ksz9477_reg.h
index 7a2c8d4767af..abdd653a2f39 100644
--- a/drivers/net/dsa/microchip/ksz9477_reg.h
+++ b/drivers/net/dsa/microchip/ksz9477_reg.h
@@ -345,13 +345,6 @@
#define REG_SW_MAC_TOS_PRIO_30 0x035E
#define REG_SW_MAC_TOS_PRIO_31 0x035F
-#define REG_SW_MRI_CTRL_0 0x0370
-
-#define SW_IGMP_SNOOP BIT(6)
-#define SW_IPV6_MLD_OPTION BIT(3)
-#define SW_IPV6_MLD_SNOOP BIT(2)
-#define SW_MIRROR_RX_TX BIT(0)
-
#define REG_SW_CLASS_D_IP_CTRL__4 0x0374
#define SW_CLASS_D_IP_ENABLE BIT(31)
@@ -1406,12 +1399,6 @@
#define REG_PORT_ACL_CTRL_1 0x0613
/* 8 - Classification and Policing */
-#define REG_PORT_MRI_MIRROR_CTRL 0x0800
-
-#define PORT_MIRROR_RX BIT(6)
-#define PORT_MIRROR_TX BIT(5)
-#define PORT_MIRROR_SNIFFER BIT(1)
-
#define REG_PORT_MRI_PRIO_CTRL 0x0801
#define PORT_HIGHEST_PRIO BIT(7)
@@ -1628,7 +1615,6 @@
#define P_BCAST_STORM_CTRL REG_PORT_MAC_CTRL_0
#define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL
-#define P_MIRROR_CTRL REG_PORT_MRI_MIRROR_CTRL
#define P_STP_CTRL REG_PORT_LUE_MSTP_STATE
#define P_PHY_CTRL REG_PORT_PHY_CTRL
#define P_NEG_RESTART_CTRL REG_PORT_PHY_CTRL
@@ -1637,7 +1623,6 @@
#define P_RATE_LIMIT_CTRL REG_PORT_MAC_IN_RATE_LIMIT
#define S_LINK_AGING_CTRL REG_SW_LUE_CTRL_1
-#define S_MIRROR_CTRL REG_SW_MRI_CTRL_0
#define S_REPLACE_VID_CTRL REG_SW_MAC_CTRL_2
#define S_802_1P_PRIO_CTRL REG_SW_MAC_802_1P_MAP_0
#define S_TOS_PRIO_CTRL REG_SW_MAC_TOS_PRIO_0
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 9b9f570ebb0b..ec5759b017d9 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -19,6 +19,78 @@
#include <net/switchdev.h>
#include "ksz_common.h"
+#include "ksz_reg.h"
+
+int ksz_port_mirror_add(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror,
+ bool ingress, struct netlink_ext_ack *extack)
+{
+ struct ksz_device *dev = ds->priv;
+ u8 data;
+ int p;
+
+ /* Limit to one sniffer port
+ * Check if any of the port is already set for sniffing
+ * If yes, instruct the user to remove the previous entry & exit
+ */
+ for (p = 0; p < dev->port_cnt; p++) {
+ /* Skip the current sniffing port */
+ if (p == mirror->to_local_port)
+ continue;
+
+ ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
+
+ if (data & PORT_MIRROR_SNIFFER) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Sniffer port is already configured, delete existing rules & retry");
+ return -EBUSY;
+ }
+ }
+
+ if (ingress)
+ ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, true);
+ else
+ ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, true);
+
+ /* configure mirror port */
+ ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
+ PORT_MIRROR_SNIFFER, true);
+
+ ksz_cfg(dev, S_MIRROR_CTRL, SW_MIRROR_RX_TX, false);
+
+ return 0;
+}
+EXPORT_SYMBOL(ksz_port_mirror_add);
+
+void ksz_port_mirror_del(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror)
+{
+ struct ksz_device *dev = ds->priv;
+ bool in_use = false;
+ u8 data;
+ int p;
+
+ if (mirror->ingress)
+ ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, false);
+ else
+ ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, false);
+
+ /* Check if any of the port is still referring to sniffer port */
+ for (p = 0; p < dev->port_cnt; p++) {
+ ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
+
+ if ((data & (PORT_MIRROR_RX | PORT_MIRROR_TX))) {
+ in_use = true;
+ break;
+ }
+ }
+
+ /* delete sniffing if there are no other mirroring rule exist */
+ if (!in_use)
+ ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
+ PORT_MIRROR_SNIFFER, false);
+}
+EXPORT_SYMBOL(ksz_port_mirror_del);
void ksz_update_port_member(struct ksz_device *dev, int port)
{
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 4f049e9d8952..e8eeafc03bf7 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -177,6 +177,11 @@ int ksz_port_mdb_del(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb,
struct dsa_db db);
int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy);
+int ksz_port_mirror_add(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror,
+ bool ingress, struct netlink_ext_ack *extack);
+void ksz_port_mirror_del(struct dsa_switch *ds, int port,
+ struct dsa_mall_mirror_tc_entry *mirror);
/* Common register access functions */
diff --git a/drivers/net/dsa/microchip/ksz_reg.h b/drivers/net/dsa/microchip/ksz_reg.h
new file mode 100644
index 000000000000..ccd4a6568e34
--- /dev/null
+++ b/drivers/net/dsa/microchip/ksz_reg.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Microchip KSZ Switch register definitions
+ *
+ * Copyright (C) 2017-2022 Microchip Technology Inc.
+ */
+
+#ifndef __KSZ_REGS_H
+#define __KSZ_REGS_H
+
+#define REG_SW_MRI_CTRL_0 0x0370
+
+#define SW_IGMP_SNOOP BIT(6)
+#define SW_IPV6_MLD_OPTION BIT(3)
+#define SW_IPV6_MLD_SNOOP BIT(2)
+#define SW_MIRROR_RX_TX BIT(0)
+
+/* 8 - Classification and Policing */
+#define REG_PORT_MRI_MIRROR_CTRL 0x0800
+
+#define PORT_MIRROR_RX BIT(6)
+#define PORT_MIRROR_TX BIT(5)
+#define PORT_MIRROR_SNIFFER BIT(1)
+
+#define P_MIRROR_CTRL REG_PORT_MRI_MIRROR_CTRL
+
+#define S_MIRROR_CTRL REG_SW_MRI_CTRL_0
+
+#endif
--
2.33.0
^ permalink raw reply related
* [RFC patch net-next 1/3] net: dsa: ksz9477: port mirror sniffing limited to one port
From: Arun Ramadoss @ 2022-04-27 16:23 UTC (permalink / raw)
To: linux-kernel, netdev
Cc: Paolo Abeni, Jakub Kicinski, David S. Miller, Vladimir Oltean,
Florian Fainelli, Vivien Didelot, Andrew Lunn, UNGLinuxDriver,
Woojung Huh
In-Reply-To: <20220427162343.18092-1-arun.ramadoss@microchip.com>
This patch limits the sniffing to only one port during the mirror add.
And during the mirror_del it checks for all the ports using the sniff,
if and only if no other ports are referring, sniffing is disabled.
The code is updated based on the review comments of LAN937x port mirror
patch.
https://patchwork.kernel.org/project/netdevbpf/patch/20210422094257.1641396-8-prasanna.vengateshan@microchip.com/
Signed-off-by: Prasanna Vengateshan <prasanna.vengateshan@microchip.com>
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
drivers/net/dsa/microchip/ksz9477.c | 38 ++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 4f617fee9a4e..90ce789107eb 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -990,14 +990,32 @@ static int ksz9477_port_mirror_add(struct dsa_switch *ds, int port,
bool ingress, struct netlink_ext_ack *extack)
{
struct ksz_device *dev = ds->priv;
+ u8 data;
+ int p;
+
+ /* Limit to one sniffer port
+ * Check if any of the port is already set for sniffing
+ * If yes, instruct the user to remove the previous entry & exit
+ */
+ for (p = 0; p < dev->port_cnt; p++) {
+ /* Skip the current sniffing port */
+ if (p == mirror->to_local_port)
+ continue;
+
+ ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
+
+ if (data & PORT_MIRROR_SNIFFER) {
+ NL_SET_ERR_MSG_MOD(extack,
+ "Sniffer port is already configured, delete existing rules & retry");
+ return -EBUSY;
+ }
+ }
if (ingress)
ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, true);
else
ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, true);
- ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_SNIFFER, false);
-
/* configure mirror port */
ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
PORT_MIRROR_SNIFFER, true);
@@ -1011,16 +1029,28 @@ static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port,
struct dsa_mall_mirror_tc_entry *mirror)
{
struct ksz_device *dev = ds->priv;
+ bool in_use = false;
u8 data;
+ int p;
if (mirror->ingress)
ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_RX, false);
else
ksz_port_cfg(dev, port, P_MIRROR_CTRL, PORT_MIRROR_TX, false);
- ksz_pread8(dev, port, P_MIRROR_CTRL, &data);
- if (!(data & (PORT_MIRROR_RX | PORT_MIRROR_TX)))
+ /* Check if any of the port is still referring to sniffer port */
+ for (p = 0; p < dev->port_cnt; p++) {
+ ksz_pread8(dev, p, P_MIRROR_CTRL, &data);
+
+ if ((data & (PORT_MIRROR_RX | PORT_MIRROR_TX))) {
+ in_use = true;
+ break;
+ }
+ }
+
+ /* delete sniffing if there are no other mirroring rule exist */
+ if (!in_use)
ksz_port_cfg(dev, mirror->to_local_port, P_MIRROR_CTRL,
PORT_MIRROR_SNIFFER, false);
}
--
2.33.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox