Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7bbc7f4 authored by Vasu Dev's avatar Vasu Dev Committed by James Bottomley
Browse files

[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: default avatarVasu Dev <vasu.dev@intel.com>
Signed-off-by: default avatarRobert Love <robert.w.love@intel.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 1875f27e
Loading
Loading
Loading
Loading
+4 −11
Original line number Original line Diff line number Diff line
@@ -505,18 +505,11 @@ static int fc_fcp_send_data(struct fc_fcp_pkt *fsp, struct fc_seq *seq,
			 */
			 */
			if (tlen % 4)
			if (tlen % 4)
				using_sg = 0;
				using_sg = 0;
			if (using_sg) {
			fp = fc_frame_alloc(lport, using_sg ? 0 : tlen);
				fp = _fc_frame_alloc(lport, 0);
				if (!fp)
					return -ENOMEM;
			} else {
				fp = fc_frame_alloc(lport, tlen);
			if (!fp)
			if (!fp)
				return -ENOMEM;
				return -ENOMEM;


				data = (void *)(fr_hdr(fp)) +
			data = fc_frame_header_get(fp) + 1;
					sizeof(struct fc_frame_header);
			}
			fh_parm_offset = frame_offset;
			fh_parm_offset = frame_offset;
			fr_max_payload(fp) = fsp->max_payload;
			fr_max_payload(fp) = fsp->max_payload;
		}
		}
+3 −3
Original line number Original line Diff line number Diff line
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(fc_frame_crc_check);
 * Allocate a frame intended to be sent via fcoe_xmit.
 * Allocate a frame intended to be sent via fcoe_xmit.
 * Get an sk_buff for the frame and set the length.
 * Get an sk_buff for the frame and set the length.
 */
 */
struct fc_frame *__fc_frame_alloc(size_t len)
struct fc_frame *_fc_frame_alloc(size_t len)
{
{
	struct fc_frame *fp;
	struct fc_frame *fp;
	struct sk_buff *skb;
	struct sk_buff *skb;
@@ -67,7 +67,7 @@ struct fc_frame *__fc_frame_alloc(size_t len)
	skb_put(skb, len);
	skb_put(skb, len);
	return fp;
	return fp;
}
}
EXPORT_SYMBOL(__fc_frame_alloc);
EXPORT_SYMBOL(_fc_frame_alloc);


struct fc_frame *fc_frame_alloc_fill(struct fc_lport *lp, size_t payload_len)
struct fc_frame *fc_frame_alloc_fill(struct fc_lport *lp, size_t payload_len)
{
{
@@ -77,7 +77,7 @@ struct fc_frame *fc_frame_alloc_fill(struct fc_lport *lp, size_t payload_len)
	fill = payload_len % 4;
	fill = payload_len % 4;
	if (fill != 0)
	if (fill != 0)
		fill = 4 - fill;
		fill = 4 - fill;
	fp = __fc_frame_alloc(payload_len + fill);
	fp = _fc_frame_alloc(payload_len + fill);
	if (fp) {
	if (fp) {
		memset((char *) fr_hdr(fp) + payload_len, 0, fill);
		memset((char *) fr_hdr(fp) + payload_len, 0, fill);
		/* trim is OK, we just allocated it so there are no fragments */
		/* trim is OK, we just allocated it so there are no fragments */
+3 −13
Original line number Original line Diff line number Diff line
@@ -100,17 +100,7 @@ static inline void fc_frame_init(struct fc_frame *fp)
}
}


struct fc_frame *fc_frame_alloc_fill(struct fc_lport *, size_t payload_len);
struct fc_frame *fc_frame_alloc_fill(struct fc_lport *, size_t payload_len);

struct fc_frame *_fc_frame_alloc(size_t payload_len);
struct fc_frame *__fc_frame_alloc(size_t payload_len);

/*
 * Get frame for sending via port.
 */
static inline struct fc_frame *_fc_frame_alloc(struct fc_lport *dev,
					       size_t payload_len)
{
	return __fc_frame_alloc(payload_len);
}


/*
/*
 * Allocate fc_frame structure and buffer.  Set the initial length to
 * 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)
	 * Note: Since len will often be a constant multiple of 4,
	 * Note: Since len will often be a constant multiple of 4,
	 * this check will usually be evaluated and eliminated at compile time.
	 * this check will usually be evaluated and eliminated at compile time.
	 */
	 */
	if ((len % 4) != 0)
	if (len && len % 4)
		fp = fc_frame_alloc_fill(dev, len);
		fp = fc_frame_alloc_fill(dev, len);
	else
	else
		fp = _fc_frame_alloc(dev, len);
		fp = _fc_frame_alloc(len);
	return fp;
	return fp;
}
}