Skip to content

Commit 820f210

Browse files
Stefan Raspldavem330
authored andcommitted
s390/ism: Consolidate SMC-D-related code
The ism module had SMC-D-specific code sprinkled across the entire module. We are now consolidating the SMC-D-specific parts into the latter parts of the module, so it becomes more clear what code is intended for use with ISM, and which parts are glue code for usage in the context of SMC-D. This is the fourth 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 9de4df7 commit 820f210

File tree

4 files changed

+143
-89
lines changed

4 files changed

+143
-89
lines changed

drivers/s390/net/ism_drv.c

Lines changed: 99 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,6 @@ static int ism_query_rgid(struct ism_dev *ism, u64 rgid, u32 vid_valid,
289289
return ism_cmd(ism, &cmd);
290290
}
291291

292-
static int smcd_query_rgid(struct smcd_dev *smcd, u64 rgid, u32 vid_valid, u32 vid)
293-
{
294-
return ism_query_rgid(smcd->priv, rgid, vid_valid, vid);
295-
}
296-
297292
static void ism_free_dmb(struct ism_dev *ism, struct ism_dmb *dmb)
298293
{
299294
clear_bit(dmb->sba_idx, ism->sba_bitmap);
@@ -363,11 +358,6 @@ int ism_register_dmb(struct ism_dev *ism, struct ism_dmb *dmb,
363358
}
364359
EXPORT_SYMBOL_GPL(ism_register_dmb);
365360

366-
static int smcd_register_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb)
367-
{
368-
return ism_register_dmb(smcd->priv, (struct ism_dmb *)dmb, NULL);
369-
}
370-
371361
int ism_unregister_dmb(struct ism_dev *ism, struct ism_dmb *dmb)
372362
{
373363
union ism_unreg_dmb cmd;
@@ -391,11 +381,6 @@ int ism_unregister_dmb(struct ism_dev *ism, struct ism_dmb *dmb)
391381
}
392382
EXPORT_SYMBOL_GPL(ism_unregister_dmb);
393383

394-
static int smcd_unregister_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb)
395-
{
396-
return ism_unregister_dmb(smcd->priv, (struct ism_dmb *)dmb);
397-
}
398-
399384
static int ism_add_vlan_id(struct ism_dev *ism, u64 vlan_id)
400385
{
401386
union ism_set_vlan_id cmd;
@@ -409,11 +394,6 @@ static int ism_add_vlan_id(struct ism_dev *ism, u64 vlan_id)
409394
return ism_cmd(ism, &cmd);
410395
}
411396

412-
static int smcd_add_vlan_id(struct smcd_dev *smcd, u64 vlan_id)
413-
{
414-
return ism_add_vlan_id(smcd->priv, vlan_id);
415-
}
416-
417397
static int ism_del_vlan_id(struct ism_dev *ism, u64 vlan_id)
418398
{
419399
union ism_set_vlan_id cmd;
@@ -427,25 +407,9 @@ static int ism_del_vlan_id(struct ism_dev *ism, u64 vlan_id)
427407
return ism_cmd(ism, &cmd);
428408
}
429409

430-
static int smcd_del_vlan_id(struct smcd_dev *smcd, u64 vlan_id)
431-
{
432-
return ism_del_vlan_id(smcd->priv, vlan_id);
433-
}
434-
435-
static int ism_set_vlan_required(struct smcd_dev *smcd)
410+
static int ism_signal_ieq(struct ism_dev *ism, u64 rgid, u32 trigger_irq,
411+
u32 event_code, u64 info)
436412
{
437-
return ism_cmd_simple(smcd->priv, ISM_SET_VLAN);
438-
}
439-
440-
static int ism_reset_vlan_required(struct smcd_dev *smcd)
441-
{
442-
return ism_cmd_simple(smcd->priv, ISM_RESET_VLAN);
443-
}
444-
445-
static int smcd_signal_ieq(struct smcd_dev *smcd, u64 rgid, u32 trigger_irq,
446-
u32 event_code, u64 info)
447-
{
448-
struct ism_dev *ism = smcd->priv;
449413
union ism_sig_ieq cmd;
450414

451415
memset(&cmd, 0, sizeof(cmd));
@@ -466,11 +430,9 @@ static unsigned int max_bytes(unsigned int start, unsigned int len,
466430
return min(boundary - (start & (boundary - 1)), len);
467431
}
468432

469-
static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
470-
bool sf, unsigned int offset, void *data,
471-
unsigned int size)
433+
int ism_move(struct ism_dev *ism, u64 dmb_tok, unsigned int idx, bool sf,
434+
unsigned int offset, void *data, unsigned int size)
472435
{
473-
struct ism_dev *ism = smcd->priv;
474436
unsigned int bytes;
475437
u64 dmb_req;
476438
int ret;
@@ -491,6 +453,7 @@ static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
491453

492454
return 0;
493455
}
456+
EXPORT_SYMBOL_GPL(ism_move);
494457

495458
static struct ism_systemeid SYSTEM_EID = {
496459
.seid_string = "IBM-SYSZ-ISMSEID00000000",
@@ -518,10 +481,8 @@ u8 *ism_get_seid(void)
518481
}
519482
EXPORT_SYMBOL_GPL(ism_get_seid);
520483

521-
static u16 smcd_get_chid(struct smcd_dev *smcd)
484+
static u16 ism_get_chid(struct ism_dev *ism)
522485
{
523-
struct ism_dev *ism = smcd->priv;
524-
525486
if (!ism || !ism->pdev)
526487
return 0;
527488

@@ -583,28 +544,11 @@ static irqreturn_t ism_handle_irq(int irq, void *data)
583544
return IRQ_HANDLED;
584545
}
585546

586-
static u64 smcd_get_local_gid(struct smcd_dev *smcd)
547+
static u64 ism_get_local_gid(struct ism_dev *ism)
587548
{
588-
struct ism_dev *ism = smcd->priv;
589-
590549
return ism->local_gid;
591550
}
592551

593-
static const struct smcd_ops ism_ops = {
594-
.query_remote_gid = smcd_query_rgid,
595-
.register_dmb = smcd_register_dmb,
596-
.unregister_dmb = smcd_unregister_dmb,
597-
.add_vlan_id = smcd_add_vlan_id,
598-
.del_vlan_id = smcd_del_vlan_id,
599-
.set_vlan_required = ism_set_vlan_required,
600-
.reset_vlan_required = ism_reset_vlan_required,
601-
.signal_event = smcd_signal_ieq,
602-
.move_data = smcd_move,
603-
.get_system_eid = ism_get_seid,
604-
.get_local_gid = smcd_get_local_gid,
605-
.get_chid = smcd_get_chid,
606-
};
607-
608552
static void ism_dev_add_work_func(struct work_struct *work)
609553
{
610554
struct ism_client *client = container_of(work, struct ism_client,
@@ -846,3 +790,95 @@ static void __exit ism_exit(void)
846790

847791
module_init(ism_init);
848792
module_exit(ism_exit);
793+
794+
/*************************** SMC-D Implementation *****************************/
795+
796+
#if IS_ENABLED(CONFIG_SMC)
797+
static int smcd_query_rgid(struct smcd_dev *smcd, u64 rgid, u32 vid_valid,
798+
u32 vid)
799+
{
800+
return ism_query_rgid(smcd->priv, rgid, vid_valid, vid);
801+
}
802+
803+
static int smcd_register_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb,
804+
struct ism_client *client)
805+
{
806+
return ism_register_dmb(smcd->priv, (struct ism_dmb *)dmb, client);
807+
}
808+
809+
static int smcd_unregister_dmb(struct smcd_dev *smcd, struct smcd_dmb *dmb)
810+
{
811+
return ism_unregister_dmb(smcd->priv, (struct ism_dmb *)dmb);
812+
}
813+
814+
static int smcd_add_vlan_id(struct smcd_dev *smcd, u64 vlan_id)
815+
{
816+
return ism_add_vlan_id(smcd->priv, vlan_id);
817+
}
818+
819+
static int smcd_del_vlan_id(struct smcd_dev *smcd, u64 vlan_id)
820+
{
821+
return ism_del_vlan_id(smcd->priv, vlan_id);
822+
}
823+
824+
static int smcd_set_vlan_required(struct smcd_dev *smcd)
825+
{
826+
return ism_cmd_simple(smcd->priv, ISM_SET_VLAN);
827+
}
828+
829+
static int smcd_reset_vlan_required(struct smcd_dev *smcd)
830+
{
831+
return ism_cmd_simple(smcd->priv, ISM_RESET_VLAN);
832+
}
833+
834+
static int smcd_signal_ieq(struct smcd_dev *smcd, u64 rgid, u32 trigger_irq,
835+
u32 event_code, u64 info)
836+
{
837+
return ism_signal_ieq(smcd->priv, rgid, trigger_irq, event_code, info);
838+
}
839+
840+
static int smcd_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
841+
bool sf, unsigned int offset, void *data,
842+
unsigned int size)
843+
{
844+
return ism_move(smcd->priv, dmb_tok, idx, sf, offset, data, size);
845+
}
846+
847+
static u64 smcd_get_local_gid(struct smcd_dev *smcd)
848+
{
849+
return ism_get_local_gid(smcd->priv);
850+
}
851+
852+
static u16 smcd_get_chid(struct smcd_dev *smcd)
853+
{
854+
return ism_get_chid(smcd->priv);
855+
}
856+
857+
static inline struct device *smcd_get_dev(struct smcd_dev *dev)
858+
{
859+
struct ism_dev *ism = dev->priv;
860+
861+
return &ism->dev;
862+
}
863+
864+
static const struct smcd_ops ism_ops = {
865+
.query_remote_gid = smcd_query_rgid,
866+
.register_dmb = smcd_register_dmb,
867+
.unregister_dmb = smcd_unregister_dmb,
868+
.add_vlan_id = smcd_add_vlan_id,
869+
.del_vlan_id = smcd_del_vlan_id,
870+
.set_vlan_required = smcd_set_vlan_required,
871+
.reset_vlan_required = smcd_reset_vlan_required,
872+
.signal_event = smcd_signal_ieq,
873+
.move_data = smcd_move,
874+
.get_system_eid = ism_get_seid,
875+
.get_local_gid = smcd_get_local_gid,
876+
.get_chid = smcd_get_chid,
877+
};
878+
879+
const struct smcd_ops *ism_get_smcd_ops(void)
880+
{
881+
return &ism_ops;
882+
}
883+
EXPORT_SYMBOL_GPL(ism_get_smcd_ops);
884+
#endif

include/linux/ism.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,6 @@ int ism_move(struct ism_dev *dev, u64 dmb_tok, unsigned int idx, bool sf,
9494
unsigned int offset, void *data, unsigned int size);
9595
u8 *ism_get_seid(void);
9696

97+
const struct smcd_ops *ism_get_smcd_ops(void);
98+
9799
#endif /* _ISM_H */

include/net/smc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ struct smcd_dmb {
5050
#define ISM_ERROR 0xFFFF
5151

5252
struct smcd_dev;
53+
struct ism_client;
5354

5455
struct smcd_ops {
5556
int (*query_remote_gid)(struct smcd_dev *dev, u64 rgid, u32 vid_valid,
5657
u32 vid);
57-
int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
58+
int (*register_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb,
59+
struct ism_client *client);
5860
int (*unregister_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
5961
int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
6062
int (*del_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
@@ -73,7 +75,6 @@ struct smcd_ops {
7375
struct smcd_dev {
7476
const struct smcd_ops *ops;
7577
struct device dev;
76-
struct ism_dev *ism;
7778
void *priv;
7879
struct list_head list;
7980
spinlock_t lock;

net/smc/smc_ism.c

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct smcd_dev_list smcd_dev_list = {
2727
static bool smc_ism_v2_capable;
2828
static u8 smc_ism_v2_system_eid[SMC_MAX_EID_LEN];
2929

30+
#if IS_ENABLED(CONFIG_ISM)
3031
static void smcd_register_dev(struct ism_dev *ism);
3132
static void smcd_unregister_dev(struct ism_dev *ism);
3233
static void smcd_handle_event(struct ism_dev *ism, struct ism_event *event);
@@ -40,6 +41,7 @@ static struct ism_client smc_ism_client = {
4041
.handle_event = smcd_handle_event,
4142
.handle_irq = smcd_handle_irq,
4243
};
44+
#endif
4345

4446
/* Test if an ISM communication is possible - same CPC */
4547
int smc_ism_cantalk(u64 peer_gid, unsigned short vlan_id, struct smcd_dev *smcd)
@@ -198,6 +200,7 @@ int smc_ism_unregister_dmb(struct smcd_dev *smcd, struct smc_buf_desc *dmb_desc)
198200
int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len,
199201
struct smc_buf_desc *dmb_desc)
200202
{
203+
#if IS_ENABLED(CONFIG_ISM)
201204
struct smcd_dmb dmb;
202205
int rc;
203206

@@ -206,7 +209,7 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len,
206209
dmb.sba_idx = dmb_desc->sba_idx;
207210
dmb.vlan_id = lgr->vlan_id;
208211
dmb.rgid = lgr->peer_gid;
209-
rc = lgr->smcd->ops->register_dmb(lgr->smcd, &dmb);
212+
rc = lgr->smcd->ops->register_dmb(lgr->smcd, &dmb, &smc_ism_client);
210213
if (!rc) {
211214
dmb_desc->sba_idx = dmb.sba_idx;
212215
dmb_desc->token = dmb.dmb_tok;
@@ -215,6 +218,9 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len,
215218
dmb_desc->len = dmb.dmb_len;
216219
}
217220
return rc;
221+
#else
222+
return 0;
223+
#endif
218224
}
219225

220226
static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd,
@@ -308,6 +314,7 @@ int smcd_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb)
308314
return skb->len;
309315
}
310316

317+
#if IS_ENABLED(CONFIG_ISM)
311318
struct smc_ism_event_work {
312319
struct work_struct work;
313320
struct smcd_dev *smcd;
@@ -351,24 +358,6 @@ static void smcd_handle_sw_event(struct smc_ism_event_work *wrk)
351358
}
352359
}
353360

354-
int smc_ism_signal_shutdown(struct smc_link_group *lgr)
355-
{
356-
int rc;
357-
union smcd_sw_event_info ev_info;
358-
359-
if (lgr->peer_shutdown)
360-
return 0;
361-
362-
memcpy(ev_info.uid, lgr->id, SMC_LGR_ID_SIZE);
363-
ev_info.vlan_id = lgr->vlan_id;
364-
ev_info.code = ISM_EVENT_REQUEST;
365-
rc = lgr->smcd->ops->signal_event(lgr->smcd, lgr->peer_gid,
366-
ISM_EVENT_REQUEST_IR,
367-
ISM_EVENT_CODE_SHUTDOWN,
368-
ev_info.info);
369-
return rc;
370-
}
371-
372361
/* worker for SMC-D events */
373362
static void smc_ism_event_work(struct work_struct *work)
374363
{
@@ -442,9 +431,12 @@ EXPORT_SYMBOL_GPL(smcd_free_dev);
442431

443432
static void smcd_register_dev(struct ism_dev *ism)
444433
{
445-
const struct smcd_ops *ops = NULL;
434+
const struct smcd_ops *ops = ism_get_smcd_ops();
446435
struct smcd_dev *smcd;
447436

437+
if (!ops)
438+
return;
439+
448440
smcd = smcd_alloc_dev(&ism->pdev->dev, dev_name(&ism->pdev->dev), ops,
449441
ISM_NR_DMBS);
450442
if (!smcd)
@@ -550,16 +542,39 @@ static void smcd_handle_irq(struct ism_dev *ism, unsigned int dmbno,
550542
tasklet_schedule(&conn->rx_tsklet);
551543
spin_unlock_irqrestore(&smcd->lock, flags);
552544
}
545+
#endif
546+
547+
int smc_ism_signal_shutdown(struct smc_link_group *lgr)
548+
{
549+
int rc = 0;
550+
#if IS_ENABLED(CONFIG_ISM)
551+
union smcd_sw_event_info ev_info;
552+
553+
if (lgr->peer_shutdown)
554+
return 0;
555+
556+
memcpy(ev_info.uid, lgr->id, SMC_LGR_ID_SIZE);
557+
ev_info.vlan_id = lgr->vlan_id;
558+
ev_info.code = ISM_EVENT_REQUEST;
559+
rc = lgr->smcd->ops->signal_event(lgr->smcd, lgr->peer_gid,
560+
ISM_EVENT_REQUEST_IR,
561+
ISM_EVENT_CODE_SHUTDOWN,
562+
ev_info.info);
563+
#endif
564+
return rc;
565+
}
553566

554567
int smc_ism_init(void)
555568
{
569+
int rc = 0;
570+
571+
#if IS_ENABLED(CONFIG_ISM)
556572
smc_ism_v2_capable = false;
557573
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;
574+
575+
rc = ism_register_client(&smc_ism_client);
562576
#endif
577+
return rc;
563578
}
564579

565580
void smc_ism_exit(void)

0 commit comments

Comments
 (0)