Skip to content

Commit 8747716

Browse files
Stefan Raspldavem330
authored andcommitted
net/smc: Register SMC-D as ISM client
Register the smc module with the new ism device driver API. This is the second part of a bigger overhaul of the interfaces between SMC and ISM. Signed-off-by: Stefan Raspl <[email protected]> Signed-off-by: Jan Karcher <[email protected]> Signed-off-by: Wenjia Zhang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 89e7d2b commit 8747716

File tree

6 files changed

+69
-35
lines changed

6 files changed

+69
-35
lines changed

drivers/s390/net/ism_drv.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,6 @@ static int ism_dev_init(struct ism_dev *ism)
642642
list_add(&ism->list, &ism_dev_list.list);
643643
mutex_unlock(&ism_dev_list.mutex);
644644

645-
ret = smcd_register_dev(ism->smcd);
646-
if (ret)
647-
goto unreg_ieq;
648-
649645
query_info(ism);
650646
return 0;
651647

@@ -748,7 +744,6 @@ static void ism_dev_exit(struct ism_dev *ism)
748744

749745
wait_event(ism->waitq, !atomic_read(&ism->free_clients_cnt));
750746

751-
smcd_unregister_dev(ism->smcd);
752747
if (SYSTEM_EID.serial_number[0] != '0' ||
753748
SYSTEM_EID.type[0] != '0')
754749
ism_del_vlan_id(ism->smcd, ISM_RESERVED_VLANID);

include/net/smc.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ struct smcd_dev {
9090

9191
struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
9292
const struct smcd_ops *ops, int max_dmbs);
93-
int smcd_register_dev(struct smcd_dev *smcd);
94-
void smcd_unregister_dev(struct smcd_dev *smcd);
9593
void smcd_free_dev(struct smcd_dev *smcd);
96-
void smcd_handle_event(struct smcd_dev *dev, struct ism_event *event);
97-
void smcd_handle_irq(struct smcd_dev *dev, unsigned int bit, u16 dmbemask);
94+
9895
#endif /* _SMC_H */

net/smc/af_smc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3382,12 +3382,14 @@ static int __init smc_init(void)
33823382
if (rc)
33833383
goto out_pernet_subsys;
33843384

3385-
smc_ism_init();
3385+
rc = smc_ism_init();
3386+
if (rc)
3387+
goto out_pernet_subsys_stat;
33863388
smc_clc_init();
33873389

33883390
rc = smc_nl_init();
33893391
if (rc)
3390-
goto out_pernet_subsys_stat;
3392+
goto out_ism;
33913393

33923394
rc = smc_pnet_init();
33933395
if (rc)
@@ -3480,6 +3482,8 @@ static int __init smc_init(void)
34803482
smc_pnet_exit();
34813483
out_nl:
34823484
smc_nl_exit();
3485+
out_ism:
3486+
smc_ism_exit();
34833487
out_pernet_subsys_stat:
34843488
unregister_pernet_subsys(&smc_net_stat_ops);
34853489
out_pernet_subsys:

net/smc/smc_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,6 +2595,7 @@ static int smc_core_reboot_event(struct notifier_block *this,
25952595
{
25962596
smc_lgrs_shutdown();
25972597
smc_ib_unregister_client();
2598+
smc_ism_exit();
25982599
return 0;
25992600
}
26002601

net/smc/smc_ism.c

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "smc_ism.h"
1818
#include "smc_pnet.h"
1919
#include "smc_netlink.h"
20+
#include "linux/ism.h"
2021

2122
struct smcd_dev_list smcd_dev_list = {
2223
.list = LIST_HEAD_INIT(smcd_dev_list.list),
@@ -26,6 +27,20 @@ struct smcd_dev_list smcd_dev_list = {
2627
static bool smc_ism_v2_capable;
2728
static u8 smc_ism_v2_system_eid[SMC_MAX_EID_LEN];
2829

30+
static void smcd_register_dev(struct ism_dev *ism);
31+
static void smcd_unregister_dev(struct ism_dev *ism);
32+
static void smcd_handle_event(struct ism_dev *ism, struct ism_event *event);
33+
static void smcd_handle_irq(struct ism_dev *ism, unsigned int dmbno,
34+
u16 dmbemask);
35+
36+
static struct ism_client smc_ism_client = {
37+
.name = "SMC-D",
38+
.add = smcd_register_dev,
39+
.remove = smcd_unregister_dev,
40+
.handle_event = smcd_handle_event,
41+
.handle_irq = smcd_handle_irq,
42+
};
43+
2944
/* Test if an ISM communication is possible - same CPC */
3045
int smc_ism_cantalk(u64 peer_gid, unsigned short vlan_id, struct smcd_dev *smcd)
3146
{
@@ -409,8 +424,6 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
409424
device_initialize(&smcd->dev);
410425
dev_set_name(&smcd->dev, name);
411426
smcd->ops = ops;
412-
if (smc_pnetid_by_dev_port(parent, 0, smcd->pnetid))
413-
smc_pnetid_by_table_smcd(smcd);
414427

415428
spin_lock_init(&smcd->lock);
416429
spin_lock_init(&smcd->lgr_lock);
@@ -421,9 +434,25 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
421434
}
422435
EXPORT_SYMBOL_GPL(smcd_alloc_dev);
423436

424-
int smcd_register_dev(struct smcd_dev *smcd)
437+
void smcd_free_dev(struct smcd_dev *smcd)
425438
{
426-
int rc;
439+
put_device(&smcd->dev);
440+
}
441+
EXPORT_SYMBOL_GPL(smcd_free_dev);
442+
443+
static void smcd_register_dev(struct ism_dev *ism)
444+
{
445+
const struct smcd_ops *ops = NULL;
446+
struct smcd_dev *smcd;
447+
448+
smcd = smcd_alloc_dev(&ism->pdev->dev, dev_name(&ism->pdev->dev), ops,
449+
ISM_NR_DMBS);
450+
if (!smcd)
451+
return;
452+
smcd->priv = ism;
453+
ism_set_priv(ism, &smc_ism_client, smcd);
454+
if (smc_pnetid_by_dev_port(&ism->pdev->dev, 0, smcd->pnetid))
455+
smc_pnetid_by_table_smcd(smcd);
427456

428457
mutex_lock(&smcd_dev_list.mutex);
429458
if (list_empty(&smcd_dev_list.list)) {
@@ -447,19 +476,20 @@ int smcd_register_dev(struct smcd_dev *smcd)
447476
dev_name(&smcd->dev), smcd->pnetid,
448477
smcd->pnetid_by_user ? " (user defined)" : "");
449478

450-
rc = device_add(&smcd->dev);
451-
if (rc) {
479+
if (device_add(&smcd->dev)) {
452480
mutex_lock(&smcd_dev_list.mutex);
453481
list_del(&smcd->list);
454482
mutex_unlock(&smcd_dev_list.mutex);
483+
smcd_free_dev(smcd);
455484
}
456485

457-
return rc;
486+
return;
458487
}
459-
EXPORT_SYMBOL_GPL(smcd_register_dev);
460488

461-
void smcd_unregister_dev(struct smcd_dev *smcd)
489+
static void smcd_unregister_dev(struct ism_dev *ism)
462490
{
491+
struct smcd_dev *smcd = ism_get_priv(ism, &smc_ism_client);
492+
463493
pr_warn_ratelimited("smc: removing smcd device %s\n",
464494
dev_name(&smcd->dev));
465495
smcd->going_away = 1;
@@ -471,16 +501,9 @@ void smcd_unregister_dev(struct smcd_dev *smcd)
471501

472502
device_del(&smcd->dev);
473503
}
474-
EXPORT_SYMBOL_GPL(smcd_unregister_dev);
475-
476-
void smcd_free_dev(struct smcd_dev *smcd)
477-
{
478-
put_device(&smcd->dev);
479-
}
480-
EXPORT_SYMBOL_GPL(smcd_free_dev);
481504

482505
/* SMCD Device event handler. Called from ISM device interrupt handler.
483-
* Parameters are smcd device pointer,
506+
* Parameters are ism device pointer,
484507
* - event->type (0 --> DMB, 1 --> GID),
485508
* - event->code (event code),
486509
* - event->tok (either DMB token when event type 0, or GID when event type 1)
@@ -490,8 +513,9 @@ EXPORT_SYMBOL_GPL(smcd_free_dev);
490513
* Context:
491514
* - Function called in IRQ context from ISM device driver event handler.
492515
*/
493-
void smcd_handle_event(struct smcd_dev *smcd, struct ism_event *event)
516+
static void smcd_handle_event(struct ism_dev *ism, struct ism_event *event)
494517
{
518+
struct smcd_dev *smcd = ism_get_priv(ism, &smc_ism_client);
495519
struct smc_ism_event_work *wrk;
496520

497521
if (smcd->going_away)
@@ -505,17 +529,18 @@ void smcd_handle_event(struct smcd_dev *smcd, struct ism_event *event)
505529
wrk->event = *event;
506530
queue_work(smcd->event_wq, &wrk->work);
507531
}
508-
EXPORT_SYMBOL_GPL(smcd_handle_event);
509532

510533
/* SMCD Device interrupt handler. Called from ISM device interrupt handler.
511-
* Parameters are smcd device pointer, DMB number, and the DMBE bitmask.
534+
* Parameters are the ism device pointer, DMB number, and the DMBE bitmask.
512535
* Find the connection and schedule the tasklet for this connection.
513536
*
514537
* Context:
515538
* - Function called in IRQ context from ISM device driver IRQ handler.
516539
*/
517-
void smcd_handle_irq(struct smcd_dev *smcd, unsigned int dmbno, u16 dmbemask)
540+
static void smcd_handle_irq(struct ism_dev *ism, unsigned int dmbno,
541+
u16 dmbemask)
518542
{
543+
struct smcd_dev *smcd = ism_get_priv(ism, &smc_ism_client);
519544
struct smc_connection *conn = NULL;
520545
unsigned long flags;
521546

@@ -525,10 +550,21 @@ void smcd_handle_irq(struct smcd_dev *smcd, unsigned int dmbno, u16 dmbemask)
525550
tasklet_schedule(&conn->rx_tsklet);
526551
spin_unlock_irqrestore(&smcd->lock, flags);
527552
}
528-
EXPORT_SYMBOL_GPL(smcd_handle_irq);
529553

530-
void __init smc_ism_init(void)
554+
int smc_ism_init(void)
531555
{
532556
smc_ism_v2_capable = false;
533557
memset(smc_ism_v2_system_eid, 0, SMC_MAX_EID_LEN);
558+
#if IS_ENABLED(CONFIG_ISM)
559+
return ism_register_client(&smc_ism_client);
560+
#else
561+
return 0;
562+
#endif
563+
}
564+
565+
void smc_ism_exit(void)
566+
{
567+
#if IS_ENABLED(CONFIG_ISM)
568+
ism_unregister_client(&smc_ism_client);
569+
#endif
534570
}

net/smc/smc_ism.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ int smc_ism_signal_shutdown(struct smc_link_group *lgr);
4242
void smc_ism_get_system_eid(u8 **eid);
4343
u16 smc_ism_get_chid(struct smcd_dev *dev);
4444
bool smc_ism_is_v2_capable(void);
45-
void smc_ism_init(void);
45+
int smc_ism_init(void);
46+
void smc_ism_exit(void);
4647
int smcd_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb);
4748

4849
static inline int smc_ism_write(struct smcd_dev *smcd, u64 dmb_tok,

0 commit comments

Comments
 (0)