Skip to content

Commit a7bbc7f

Browse files
Vasu DevJames Bottomley
authored andcommitted
[SCSI] fcoe, libfc: use single frame allocation API
Cleans up frame allocation APIs to have just single fc_frame_alloc API. Removes _fc_frame_alloc, renames __fc_frame_alloc to _fc_frame_alloc. Modifies fc_fcp_send_data for removed _fc_frame_alloc, fc_fcp_send_data was the only user of removed _fc_frame_alloc. Also Adds check in fc_frame_alloc to do mod by 4 for only non-zero len value. This patch is prep work to fix can_queue reducing in next patch. Single fc_frame_alloc API helps in fixing can_queue reducing in next patch. Signed-off-by: Vasu Dev <vasu.dev@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 1875f27 commit a7bbc7f

3 files changed

Lines changed: 10 additions & 27 deletions

File tree

‎drivers/scsi/libfc/fc_fcp.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,11 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq,
505505
*/
506506
if (tlen % 4)
507507
using_sg = 0;
508-
if (using_sg) {
509-
fp = _fc_frame_alloc(lport, 0);
510-
if (!fp)
511-
return -ENOMEM;
512-
} else {
513-
fp = fc_frame_alloc(lport, tlen);
514-
if (!fp)
515-
return -ENOMEM;
508+
fp = fc_frame_alloc(lport, using_sg ? 0 : tlen);
509+
if (!fp)
510+
return -ENOMEM;
516511

517-
data = (void *)(fr_hdr(fp)) +
518-
sizeof(struct fc_frame_header);
519-
}
512+
data = fc_frame_header_get(fp) + 1;
520513
fh_parm_offset = frame_offset;
521514
fr_max_payload(fp) = fsp->max_payload;
522515
}

‎drivers/scsi/libfc/fc_frame.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(fc_frame_crc_check);
5151
* Allocate a frame intended to be sent via fcoe_xmit.
5252
* Get an sk_buff for the frame and set the length.
5353
*/
54-
struct fc_frame *__fc_frame_alloc(size_t len)
54+
struct fc_frame *_fc_frame_alloc(size_t len)
5555
{
5656
struct fc_frame *fp;
5757
struct sk_buff *skb;
@@ -67,7 +67,7 @@ struct fc_frame *__fc_frame_alloc(size_t len)
6767
skb_put(skb, len);
6868
return fp;
6969
}
70-
EXPORT_SYMBOL(__fc_frame_alloc);
70+
EXPORT_SYMBOL(_fc_frame_alloc);
7171

7272
struct fc_frame *fc_frame_alloc_fill(struct fc_lport *lp, size_t payload_len)
7373
{
@@ -77,7 +77,7 @@ struct fc_frame *fc_frame_alloc_fill(struct fc_lport *lp, size_t payload_len)
7777
fill = payload_len % 4;
7878
if (fill != 0)
7979
fill = 4 - fill;
80-
fp = __fc_frame_alloc(payload_len + fill);
80+
fp = _fc_frame_alloc(payload_len + fill);
8181
if (fp) {
8282
memset((char *) fr_hdr(fp) + payload_len, 0, fill);
8383
/* trim is OK, we just allocated it so there are no fragments */

‎include/scsi/fc_frame.h‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,7 @@ static inline void fc_frame_init(struct fc_frame *fp)
100100
}
101101

102102
struct fc_frame *fc_frame_alloc_fill(struct fc_lport *, size_t payload_len);
103-
104-
struct fc_frame *__fc_frame_alloc(size_t payload_len);
105-
106-
/*
107-
* Get frame for sending via port.
108-
*/
109-
static inline struct fc_frame *_fc_frame_alloc(struct fc_lport *dev,
110-
size_t payload_len)
111-
{
112-
return __fc_frame_alloc(payload_len);
113-
}
103+
struct fc_frame *_fc_frame_alloc(size_t payload_len);
114104

115105
/*
116106
* Allocate fc_frame structure and buffer. Set the initial length to
@@ -124,10 +114,10 @@ static inline struct fc_frame *fc_frame_alloc(struct fc_lport *dev, size_t len)
124114
* Note: Since len will often be a constant multiple of 4,
125115
* this check will usually be evaluated and eliminated at compile time.
126116
*/
127-
if ((len % 4) != 0)
117+
if (len && len % 4)
128118
fp = fc_frame_alloc_fill(dev, len);
129119
else
130-
fp = _fc_frame_alloc(dev, len);
120+
fp = _fc_frame_alloc(len);
131121
return fp;
132122
}
133123

0 commit comments

Comments
 (0)