[ofa-general] [PATCH 6/10 v1] IB/mlx4: Add LSO support

Eli Cohen eli at dev.mellanox.co.il
Wed Apr 2 04:41:33 PDT 2008


On Tue, 2008-04-01 at 12:59 -0700, Roland Dreier wrote:
> > +	halign = ALIGN(wr->wr.ud.hlen, 16);
> 
> This doesn't seem connected to the problem I see, but is this correct?
> Suppose hlen is 48... then halign will be 48 but it really should be
> 64 I think.  Do we really want
> 
> 	halign = ALIGN(wr->wr.ud.hlen + sizeof *wqe, 16);
> 
> instead?
> 

I don't think so, at least in the case that hlen equals 48 which is a
valid one since the total length used by the LSO segment would be 48 + 4
which requires 4 * 16 bytes chunks. If we'd use the above statement the
send would fail.

Anyway I think this function should look like this:

static int build_lso_seg(struct mlx4_lso_seg *wqe, struct ib_send_wr *wr,
			 struct mlx4_ib_qp *qp, unsigned *lso_seg_len)
{
	unsigned halign = ALIGN(wr->wr.ud.hlen + 4, 16);

	/*
	 * This is a temporary limitation and will be removed in
	 * a forthcoming FW release:
	 */
	if (unlikely(halign > 64))
		return -EINVAL;

	if (unlikely(!(qp->flags & MLX4_IB_QP_LSO) &&
		     wr->num_sge > qp->sq.max_gs - (halign >> 4)))
		return -EINVAL;

	memcpy(wqe->header, wr->wr.ud.header, wr->wr.ud.hlen);

	/* make sure LSO header is written before overwriting stamping */
	wmb();

	wqe->mss_hdr_size = cpu_to_be32((wr->wr.ud.mss - wr->wr.ud.hlen) << 16 |
					wr->wr.ud.hlen);

	*lso_seg_len = halign;
	return 0;
}


And also I suggest to use these too:

@@ -1539,7 +1539,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,

                        if (wr->opcode == IB_WR_LSO) {
                                err = build_lso_seg(wqe, wr, qp, &seglen);
-                               if (err) {
+                               if (unlikely(err)) {
                                        *bad_wr = wr;
                                        goto out;
                                }
@@ -1551,7 +1551,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                case IB_QPT_SMI:
                case IB_QPT_GSI:
                        err = build_mlx_header(to_msqp(qp), wr, ctrl, &seglen);
-                       if (err) {
+                       if (unlikely(err)) {
                                *bad_wr = wr;
                                goto out;
                        }
@@ -1594,7 +1594,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                 */
                wmb();

-               if (wr->opcode < 0 || wr->opcode >= ARRAY_SIZE(mlx4_ib_opcode)) {
+               if (unlikely(wr->opcode < 0 || wr->opcode >= ARRAY_SIZE(mlx4_ib_opcode))) {
                        err = -EINVAL;
                        goto out;
                }





More information about the general mailing list