Skip to content

Commit b985f87

Browse files
shorman-netronomedavem330
authored andcommitted
nfp: process control messages in workqueue in flower app
Processing of control messages is not time-critical and future processing of some messages will require taking the RTNL which is not possible in a BH handler. It seems simplest to move all control message processing to a workqueue. Signed-off-by: Simon Horman <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cf9d014 commit b985f87

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

drivers/net/ethernet/netronome/nfp/flower/cmsg.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
#include <linux/bitfield.h>
3535
#include <linux/netdevice.h>
3636
#include <linux/skbuff.h>
37+
#include <linux/workqueue.h>
3738
#include <net/dst_metadata.h>
3839

3940
#include "main.h"
4041
#include "../nfpcore/nfp_cpp.h"
42+
#include "../nfp_net.h"
4143
#include "../nfp_net_repr.h"
4244
#include "./cmsg.h"
4345

@@ -155,7 +157,8 @@ nfp_flower_cmsg_portmod_rx(struct nfp_app *app, struct sk_buff *skb)
155157
rcu_read_unlock();
156158
}
157159

158-
void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb)
160+
static void
161+
nfp_flower_cmsg_process_one_rx(struct nfp_app *app, struct sk_buff *skb)
159162
{
160163
struct nfp_flower_cmsg_hdr *cmsg_hdr;
161164
enum nfp_flower_cmsg_type_port type;
@@ -184,3 +187,22 @@ void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb)
184187
out:
185188
dev_kfree_skb_any(skb);
186189
}
190+
191+
void nfp_flower_cmsg_process_rx(struct work_struct *work)
192+
{
193+
struct nfp_flower_priv *priv;
194+
struct sk_buff *skb;
195+
196+
priv = container_of(work, struct nfp_flower_priv, cmsg_work);
197+
198+
while ((skb = skb_dequeue(&priv->cmsg_skbs)))
199+
nfp_flower_cmsg_process_one_rx(priv->nn->app, skb);
200+
}
201+
202+
void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb)
203+
{
204+
struct nfp_flower_priv *priv = app->priv;
205+
206+
skb_queue_tail(&priv->cmsg_skbs, skb);
207+
schedule_work(&priv->cmsg_work);
208+
}

drivers/net/ethernet/netronome/nfp/flower/cmsg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ nfp_flower_cmsg_mac_repr_add(struct sk_buff *skb, unsigned int idx,
330330
unsigned int nbi, unsigned int nbi_port,
331331
unsigned int phys_port);
332332
int nfp_flower_cmsg_portmod(struct nfp_repr *repr, bool carrier_ok);
333+
void nfp_flower_cmsg_process_rx(struct work_struct *work);
333334
void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb);
334335
struct sk_buff *
335336
nfp_flower_cmsg_alloc(struct nfp_app *app, unsigned int size,

drivers/net/ethernet/netronome/nfp/flower/main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ static int nfp_flower_vnic_init(struct nfp_app *app, struct nfp_net *nn,
332332
static int nfp_flower_init(struct nfp_app *app)
333333
{
334334
const struct nfp_pf *pf = app->pf;
335+
struct nfp_flower_priv *app_priv;
335336
u64 version;
336337
int err;
337338

@@ -362,10 +363,14 @@ static int nfp_flower_init(struct nfp_app *app)
362363
return -EINVAL;
363364
}
364365

365-
app->priv = vzalloc(sizeof(struct nfp_flower_priv));
366-
if (!app->priv)
366+
app_priv = vzalloc(sizeof(struct nfp_flower_priv));
367+
if (!app_priv)
367368
return -ENOMEM;
368369

370+
app->priv = app_priv;
371+
skb_queue_head_init(&app_priv->cmsg_skbs);
372+
INIT_WORK(&app_priv->cmsg_work, nfp_flower_cmsg_process_rx);
373+
369374
err = nfp_flower_metadata_init(app);
370375
if (err)
371376
goto err_free_app_priv;
@@ -379,6 +384,11 @@ static int nfp_flower_init(struct nfp_app *app)
379384

380385
static void nfp_flower_clean(struct nfp_app *app)
381386
{
387+
struct nfp_flower_priv *app_priv = app->priv;
388+
389+
skb_queue_purge(&app_priv->cmsg_skbs);
390+
flush_work(&app_priv->cmsg_work);
391+
382392
nfp_flower_metadata_cleanup(app);
383393
vfree(app->priv);
384394
app->priv = NULL;

drivers/net/ethernet/netronome/nfp/flower/main.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/time64.h>
4040
#include <linux/types.h>
4141
#include <net/pkt_cls.h>
42+
#include <linux/workqueue.h>
4243

4344
struct net_device;
4445
struct nfp_app;
@@ -78,6 +79,8 @@ struct nfp_fl_stats_id {
7879
* @mask_ids: List of free mask ids
7980
* @mask_table: Hash table used to store masks
8081
* @flow_table: Hash table used to store flower rules
82+
* @cmsg_work: Workqueue for control messages processing
83+
* @cmsg_skbs: List of skbs for control message processing
8184
*/
8285
struct nfp_flower_priv {
8386
struct nfp_net *nn;
@@ -87,6 +90,8 @@ struct nfp_flower_priv {
8790
struct nfp_fl_mask_id mask_ids;
8891
DECLARE_HASHTABLE(mask_table, NFP_FLOWER_MASK_HASH_BITS);
8992
DECLARE_HASHTABLE(flow_table, NFP_FLOWER_HASH_BITS);
93+
struct work_struct cmsg_work;
94+
struct sk_buff_head cmsg_skbs;
9095
};
9196

9297
struct nfp_fl_key_ls {

0 commit comments

Comments
 (0)