From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 21 21:49:27 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DDBFAEFC for ; Fri, 21 Jun 2013 21:49:27 +0000 (UTC) (envelope-from monthadar@gmail.com) Received: from mail-wg0-x22d.google.com (mail-wg0-x22d.google.com [IPv6:2a00:1450:400c:c00::22d]) by mx1.freebsd.org (Postfix) with ESMTP id 7BF481B19 for ; Fri, 21 Jun 2013 21:49:27 +0000 (UTC) Received: by mail-wg0-f45.google.com with SMTP id j13so6961419wgh.12 for ; Fri, 21 Jun 2013 14:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=gAM1kc0ZGAVCHcHb+MZ7FT/xHQFok753uXqp5u2heYQ=; b=hzzzYy6pe3DrlnLtyCoLoYeT43kwFgxqk6SKwtTNN7WHsV5p8Q1I68M0nArl0hzmyw fnvRutcRSap7+N3UFVlMTrAjuv+KOEFeHZVzLT4DxCQn5gnK7jKugrv1tiWXfb1gaMd6 bC98LIjoyTRmuXA7LVg0yhV4Vs+lP7avBLNKYExCMi7dLSCpq5CwfxiU3dFGn6/mOGFV Nzl7MPPujzFvZbi6q16jwgteNtiRCvUnyV7jAfVhmrrMYA/FRaiYA+bHzUsB8D2Qu1jS c9K5swjQM81PYuMZ0gQKoCNO7VwsxxOhJThzHluRikU9Lad9X6x8jcT93BZOwkMHb+LW Fiag== MIME-Version: 1.0 X-Received: by 10.194.243.226 with SMTP id xb2mr10736402wjc.67.1371851366604; Fri, 21 Jun 2013 14:49:26 -0700 (PDT) Received: by 10.227.196.9 with HTTP; Fri, 21 Jun 2013 14:49:26 -0700 (PDT) Date: Fri, 21 Jun 2013 23:49:26 +0200 Message-ID: Subject: Replace Linux skb_put with mbuf m_append From: Monthadar Al Jaberi To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jun 2013 21:49:27 -0000 Hi everyone, I am porting linux skb buffers to mbufs and stumbelded on this code from artheros 6kl driver. struct htc_conn_service_msg *conn_msg; ... /* assemble connect service message */ conn_msg = (struct htc_conn_service_msg *) skb_put(skb, length); if (conn_msg == NULL) { goto free_packet; } memset(conn_msg, 0, sizeof(struct htc_conn_service_msg)); .... what skb_put does is get a pointer to the end of the buffer with engouh space to write data there. I have thought of chaning it to: struct htc_conn_service_msg conn_msg; ... memset(&conn_msg, 0, sizeof(struct htc_conn_service_msg)); .... if (m_append(m, length, (uint8_t *) &conn_msg)) { goto free_packet; } I append to the mbuf in the end. I would like to hear your opinion on this. Is there a better faster way? br, -- Monthadar Al Jaberi