Skip to content

Commit 5fa27d5

Browse files
Dirk van der Merwedavem330
authored andcommitted
nfp: resync repr state when port table sync
If the NSP port table has been refreshed, resync the representor state with the new port information. At the moment, this only entails looking for invalid ports and killing off representors associated with them. The repr instance becomes NULL which is safe since the app accessor function for reprs returns NULL when it cannot access a repr. Signed-off-by: Dirk van der Merwe <[email protected]> Signed-off-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 51ccc37 commit 5fa27d5

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

drivers/net/ethernet/netronome/nfp/nfp_net_main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ int nfp_net_refresh_port_table_sync(struct nfp_pf *pf)
611611
struct nfp_eth_table *eth_table;
612612
struct nfp_net *nn, *next;
613613
struct nfp_port *port;
614+
int err;
614615

615616
lockdep_assert_held(&pf->lock);
616617

@@ -640,6 +641,11 @@ int nfp_net_refresh_port_table_sync(struct nfp_pf *pf)
640641

641642
kfree(eth_table);
642643

644+
/* Resync repr state. This may cause reprs to be removed. */
645+
err = nfp_reprs_resync_phys_ports(pf->app);
646+
if (err)
647+
return err;
648+
643649
/* Shoot off the ports which became invalid */
644650
list_for_each_entry_safe(nn, next, &pf->vnics, vnic_list) {
645651
if (!nn->port || nn->port->type != NFP_PORT_INVALID)

drivers/net/ethernet/netronome/nfp/nfp_net_repr.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,50 @@ struct nfp_reprs *nfp_reprs_alloc(unsigned int num_reprs)
390390

391391
return reprs;
392392
}
393+
394+
int nfp_reprs_resync_phys_ports(struct nfp_app *app)
395+
{
396+
struct nfp_reprs *reprs, *old_reprs;
397+
struct nfp_repr *repr;
398+
int i;
399+
400+
old_reprs =
401+
rcu_dereference_protected(app->reprs[NFP_REPR_TYPE_PHYS_PORT],
402+
lockdep_is_held(&app->pf->lock));
403+
if (!old_reprs)
404+
return 0;
405+
406+
reprs = nfp_reprs_alloc(old_reprs->num_reprs);
407+
if (!reprs)
408+
return -ENOMEM;
409+
410+
for (i = 0; i < old_reprs->num_reprs; i++) {
411+
if (!old_reprs->reprs[i])
412+
continue;
413+
414+
repr = netdev_priv(old_reprs->reprs[i]);
415+
if (repr->port->type == NFP_PORT_INVALID)
416+
continue;
417+
418+
reprs->reprs[i] = old_reprs->reprs[i];
419+
}
420+
421+
old_reprs = nfp_app_reprs_set(app, NFP_REPR_TYPE_PHYS_PORT, reprs);
422+
synchronize_rcu();
423+
424+
/* Now we free up removed representors */
425+
for (i = 0; i < old_reprs->num_reprs; i++) {
426+
if (!old_reprs->reprs[i])
427+
continue;
428+
429+
repr = netdev_priv(old_reprs->reprs[i]);
430+
if (repr->port->type != NFP_PORT_INVALID)
431+
continue;
432+
433+
nfp_app_repr_stop(app, repr);
434+
nfp_repr_clean(repr);
435+
}
436+
437+
kfree(old_reprs);
438+
return 0;
439+
}

drivers/net/ethernet/netronome/nfp/nfp_net_repr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,6 @@ void
124124
nfp_reprs_clean_and_free_by_type(struct nfp_app *app,
125125
enum nfp_repr_type type);
126126
struct nfp_reprs *nfp_reprs_alloc(unsigned int num_reprs);
127+
int nfp_reprs_resync_phys_ports(struct nfp_app *app);
127128

128129
#endif /* NFP_NET_REPR_H */

0 commit comments

Comments
 (0)