From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roland Dreier Subject: Re: [PATCHv10 03/12] ib_core: IBoE UD packet packing support Date: Thu, 14 Oct 2010 14:43:30 -0700 Message-ID: References: <20100826141756.GD8795@mtldesk30> <20101014212658.GC13969@mtldesk30> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: In-Reply-To: <20101014212658.GC13969@mtldesk30> (Eli Cohen's message of "Thu, 14 Oct 2010 23:26:58 +0200") Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Eli Cohen Cc: RDMA list List-Id: linux-rdma@vger.kernel.org > Maybe just we should just remove any calculations on packet_length for > the Ethernet case and simplify the function farther. Makes sense-- I updated my tree to look like: void ib_ud_header_init(int payload_bytes, int lrh_present, int eth_present, int grh_present, int immediate_present, struct ib_ud_header *header) { memset(header, 0, sizeof *header); if (lrh_present) { u16 packet_length; header->lrh.link_version = 0; header->lrh.link_next_header = grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL; packet_length = (IB_LRH_BYTES + IB_BTH_BYTES + IB_DETH_BYTES + grh_present ? IB_GRH_BYTES : 0 + payload_bytes + 4 + /* ICRC */ 3) / 4; /* round up */ header->lrh.packet_length = cpu_to_be16(packet_length); } if (grh_present) { header->grh.ip_version = 6; header->grh.payload_length = cpu_to_be16((IB_BTH_BYTES + IB_DETH_BYTES + payload_bytes + 4 + /* ICRC */ 3) & ~3); /* round up */ header->grh.next_header = 0x1b; } if (header->immediate_present) header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE; else header->bth.opcode = IB_OPCODE_UD_SEND_ONLY; header->bth.pad_count = (4 - payload_bytes) & 3; header->bth.transport_header_version = 0; header->lrh_present = lrh_present; header->eth_present = eth_present; header->grh_present = grh_present; header->immediate_present = immediate_present; } which I think is reasonably clean for now. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html