Skip to content

Commit 837708a

Browse files
committed
Merge branch 'nfp-improve-signal-handing-on-FW-waits-and-flower-control-message-Jakub Kicinski says:
==================== nfp: improve signal handing on FW waits and flower control message processing The first part of this set aims to improve handling of interrupted waits. Patch 1 makes waiting for management FW responses uninterruptible while patch 2 adds a message when signal arrives while waiting for an NFP mutex. We can't interrupt execution of FW commands so uninterruptible sleep seems reasonable there. Exiting a wait for a mutex should be clean and have no side affects so we are allowing to abort it. Note that both waits have rather large timeouts (tens of seconds). Patches 3 and 4 improve flower offload operation under heavy load. Currently there is no cap on the number of queued FW notifications. Some of the notifications have to be processed from a workqueue which may lead to very large number of messages getting queued if workqueue never gets a chance to run. Pieter puts a limit on number of queued messages, tries to drop some messages we ignore without queuing and process more important messages first. ==================== Signed-off-by: David S. Miller <[email protected]> processing'
2 parents 335b929 + cf2cbad commit 837708a

File tree

6 files changed

+54
-14
lines changed

6 files changed

+54
-14
lines changed

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

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ nfp_flower_cmsg_process_one_rx(struct nfp_app *app, struct sk_buff *skb)
258258
case NFP_FLOWER_CMSG_TYPE_ACTIVE_TUNS:
259259
nfp_tunnel_keep_alive(app, skb);
260260
break;
261-
case NFP_FLOWER_CMSG_TYPE_TUN_NEIGH:
262-
/* Acks from the NFP that the route is added - ignore. */
263-
break;
264261
default:
265262
nfp_flower_cmsg_warn(app, "Cannot handle invalid repr control type %u\n",
266263
type);
@@ -275,18 +272,49 @@ nfp_flower_cmsg_process_one_rx(struct nfp_app *app, struct sk_buff *skb)
275272

276273
void nfp_flower_cmsg_process_rx(struct work_struct *work)
277274
{
275+
struct sk_buff_head cmsg_joined;
278276
struct nfp_flower_priv *priv;
279277
struct sk_buff *skb;
280278

281279
priv = container_of(work, struct nfp_flower_priv, cmsg_work);
280+
skb_queue_head_init(&cmsg_joined);
281+
282+
spin_lock_bh(&priv->cmsg_skbs_high.lock);
283+
skb_queue_splice_tail_init(&priv->cmsg_skbs_high, &cmsg_joined);
284+
spin_unlock_bh(&priv->cmsg_skbs_high.lock);
282285

283-
while ((skb = skb_dequeue(&priv->cmsg_skbs)))
286+
spin_lock_bh(&priv->cmsg_skbs_low.lock);
287+
skb_queue_splice_tail_init(&priv->cmsg_skbs_low, &cmsg_joined);
288+
spin_unlock_bh(&priv->cmsg_skbs_low.lock);
289+
290+
while ((skb = __skb_dequeue(&cmsg_joined)))
284291
nfp_flower_cmsg_process_one_rx(priv->app, skb);
285292
}
286293

287-
void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb)
294+
static void
295+
nfp_flower_queue_ctl_msg(struct nfp_app *app, struct sk_buff *skb, int type)
288296
{
289297
struct nfp_flower_priv *priv = app->priv;
298+
struct sk_buff_head *skb_head;
299+
300+
if (type == NFP_FLOWER_CMSG_TYPE_PORT_REIFY ||
301+
type == NFP_FLOWER_CMSG_TYPE_PORT_MOD)
302+
skb_head = &priv->cmsg_skbs_high;
303+
else
304+
skb_head = &priv->cmsg_skbs_low;
305+
306+
if (skb_queue_len(skb_head) >= NFP_FLOWER_WORKQ_MAX_SKBS) {
307+
nfp_flower_cmsg_warn(app, "Dropping queued control messages\n");
308+
dev_kfree_skb_any(skb);
309+
return;
310+
}
311+
312+
skb_queue_tail(skb_head, skb);
313+
schedule_work(&priv->cmsg_work);
314+
}
315+
316+
void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb)
317+
{
290318
struct nfp_flower_cmsg_hdr *cmsg_hdr;
291319

292320
cmsg_hdr = nfp_flower_cmsg_get_hdr(skb);
@@ -306,8 +334,10 @@ void nfp_flower_cmsg_rx(struct nfp_app *app, struct sk_buff *skb)
306334
nfp_flower_process_mtu_ack(app, skb)) {
307335
/* Handle MTU acks outside wq to prevent RTNL conflict. */
308336
dev_consume_skb_any(skb);
337+
} else if (cmsg_hdr->type == NFP_FLOWER_CMSG_TYPE_TUN_NEIGH) {
338+
/* Acks from the NFP that the route is added - ignore. */
339+
dev_consume_skb_any(skb);
309340
} else {
310-
skb_queue_tail(&priv->cmsg_skbs, skb);
311-
schedule_work(&priv->cmsg_work);
341+
nfp_flower_queue_ctl_msg(app, skb, cmsg_hdr->type);
312342
}
313343
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@
108108
#define NFP_FL_IPV4_TUNNEL_TYPE GENMASK(7, 4)
109109
#define NFP_FL_IPV4_PRE_TUN_INDEX GENMASK(2, 0)
110110

111+
#define NFP_FLOWER_WORKQ_MAX_SKBS 30000
112+
111113
#define nfp_flower_cmsg_warn(app, fmt, args...) \
112114
do { \
113115
if (net_ratelimit()) \

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,8 @@ static int nfp_flower_init(struct nfp_app *app)
519519

520520
app->priv = app_priv;
521521
app_priv->app = app;
522-
skb_queue_head_init(&app_priv->cmsg_skbs);
522+
skb_queue_head_init(&app_priv->cmsg_skbs_high);
523+
skb_queue_head_init(&app_priv->cmsg_skbs_low);
523524
INIT_WORK(&app_priv->cmsg_work, nfp_flower_cmsg_process_rx);
524525
init_waitqueue_head(&app_priv->reify_wait_queue);
525526

@@ -549,7 +550,8 @@ static void nfp_flower_clean(struct nfp_app *app)
549550
{
550551
struct nfp_flower_priv *app_priv = app->priv;
551552

552-
skb_queue_purge(&app_priv->cmsg_skbs);
553+
skb_queue_purge(&app_priv->cmsg_skbs_high);
554+
skb_queue_purge(&app_priv->cmsg_skbs_low);
553555
flush_work(&app_priv->cmsg_work);
554556

555557
nfp_flower_metadata_cleanup(app);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ struct nfp_mtu_conf {
107107
* @mask_table: Hash table used to store masks
108108
* @flow_table: Hash table used to store flower rules
109109
* @cmsg_work: Workqueue for control messages processing
110-
* @cmsg_skbs: List of skbs for control message processing
110+
* @cmsg_skbs_high: List of higher priority skbs for control message
111+
* processing
112+
* @cmsg_skbs_low: List of lower priority skbs for control message
113+
* processing
111114
* @nfp_mac_off_list: List of MAC addresses to offload
112115
* @nfp_mac_index_list: List of unique 8-bit indexes for non NFP netdevs
113116
* @nfp_ipv4_off_list: List of IPv4 addresses to offload
@@ -136,7 +139,8 @@ struct nfp_flower_priv {
136139
DECLARE_HASHTABLE(mask_table, NFP_FLOWER_MASK_HASH_BITS);
137140
DECLARE_HASHTABLE(flow_table, NFP_FLOWER_HASH_BITS);
138141
struct work_struct cmsg_work;
139-
struct sk_buff_head cmsg_skbs;
142+
struct sk_buff_head cmsg_skbs_high;
143+
struct sk_buff_head cmsg_skbs_low;
140144
struct list_head nfp_mac_off_list;
141145
struct list_head nfp_mac_index_list;
142146
struct list_head nfp_ipv4_off_list;

drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mutex.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,11 @@ int nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex)
211211
break;
212212

213213
err = msleep_interruptible(timeout_ms);
214-
if (err != 0)
214+
if (err != 0) {
215+
nfp_info(mutex->cpp,
216+
"interrupted waiting for NFP mutex\n");
215217
return -ERESTARTSYS;
218+
}
216219

217220
if (time_is_before_eq_jiffies(warn_at)) {
218221
warn_at = jiffies + NFP_MUTEX_WAIT_NEXT_WARN * HZ;

drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ nfp_nsp_wait_reg(struct nfp_cpp *cpp, u64 *reg, u32 nsp_cpp, u64 addr,
281281
if ((*reg & mask) == val)
282282
return 0;
283283

284-
if (msleep_interruptible(25))
285-
return -ERESTARTSYS;
284+
msleep(25);
286285

287286
if (time_after(start_time, wait_until))
288287
return -ETIMEDOUT;

0 commit comments

Comments
 (0)