Skip to content

Commit 239e810

Browse files
Joe EykholtJames Bottomley
authored andcommitted
[SCSI] libfc: add interface to allocate a sequence for incoming requests
For incoming ELS and FCP requests, we often don't require an exchange and sequence, however, sometimes we do. For those cases, (primarily FCP requests for targets) add a function to set up the exchange and sequence. Signed-off-by: Joe Eykholt <jeykholt@cisco.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 24f089e commit 239e810

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎drivers/scsi/libfc/fc_exch.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,28 @@ static void fc_exch_recv_abts(struct fc_exch *ep, struct fc_frame *rx_fp)
12301230
fc_frame_free(rx_fp);
12311231
}
12321232

1233+
/**
1234+
* fc_seq_assign() - Assign exchange and sequence for incoming request
1235+
* @lport: The local port that received the request
1236+
* @fp: The request frame
1237+
*
1238+
* On success, the sequence pointer will be returned and also in fr_seq(@fp).
1239+
*/
1240+
static struct fc_seq *fc_seq_assign(struct fc_lport *lport, struct fc_frame *fp)
1241+
{
1242+
struct fc_exch_mgr_anchor *ema;
1243+
1244+
WARN_ON(lport != fr_dev(fp));
1245+
WARN_ON(fr_seq(fp));
1246+
fr_seq(fp) = NULL;
1247+
1248+
list_for_each_entry(ema, &lport->ema_list, ema_list)
1249+
if ((!ema->match || ema->match(fp)) &&
1250+
fc_seq_lookup_recip(lport, ema->mp, fp) != FC_RJT_NONE)
1251+
break;
1252+
return fr_seq(fp);
1253+
}
1254+
12331255
/**
12341256
* fc_exch_recv_req() - Handler for an incoming request where is other
12351257
* end is originating the sequence
@@ -2283,6 +2305,9 @@ int fc_exch_init(struct fc_lport *lport)
22832305
if (!lport->tt.seq_exch_abort)
22842306
lport->tt.seq_exch_abort = fc_seq_exch_abort;
22852307

2308+
if (!lport->tt.seq_assign)
2309+
lport->tt.seq_assign = fc_seq_assign;
2310+
22862311
return 0;
22872312
}
22882313
EXPORT_SYMBOL(fc_exch_init);

‎include/scsi/libfc.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,13 @@ struct libfc_function_template {
555555
*/
556556
struct fc_seq *(*seq_start_next)(struct fc_seq *);
557557

558+
/*
559+
* Assign a sequence for an incoming request frame.
560+
*
561+
* STATUS: OPTIONAL
562+
*/
563+
struct fc_seq *(*seq_assign)(struct fc_lport *, struct fc_frame *);
564+
558565
/*
559566
* Reset an exchange manager, completing all sequences and exchanges.
560567
* If s_id is non-zero, reset only exchanges originating from that FID.

0 commit comments

Comments
 (0)