From patchwork Tue Feb 5 00:23:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1036381 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lzarCz0m"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43tlmL2cJMz9sMl for ; Tue, 5 Feb 2019 11:28:18 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D2A459BAA; Tue, 5 Feb 2019 00:27:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4987B94E5 for ; Tue, 5 Feb 2019 00:23:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1052886D for ; Tue, 5 Feb 2019 00:23:17 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id q1so709296pfi.5 for ; Mon, 04 Feb 2019 16:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=OQ+WERB5pyu5OXEY1pHq18VrJd3O2Yhxylbyv2B6tBc=; b=lzarCz0m2tEoTlHoKXbk3bwx11tmC+mWS51KlL5U8S1kYRc703/+QjvgiZU3ZZbG9X 8aZ79JJV+oIAWqDr2JmpWWlDJBv/WfAAILRmAG0NQBCmbDGyer+PonPBGl0eWw8blZpS UhlIj4BUU4P7hv9vRvdkImGg2kzTnC3vq4BQgZsLiEqDhiTGB1EIIOpWsZy5zTrfJZju UEqM1+AyDL+qqx753pP9TedkprrO3HGcChtH+QMFienSuLRMj5AiCLpRqcRQdherqMWW jk8R29xSk6H3BeRJ1zT2FcSd9WepLL2IpZG8SdfZxGhxKedCP1EwP+lJ6KU+sSl+7UIM wAPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=OQ+WERB5pyu5OXEY1pHq18VrJd3O2Yhxylbyv2B6tBc=; b=FCP2M6z7oHce1+Ud4HaRivp6H1+/YrGqU8Dig4dGoPhju4ekhkS3R52TQBSdw6hyTC yBCWeEPKdSoYirueYg6ycziX4Rmq/GAuwUez+7aM7g8tHZ2qOsKO6z24Xy7PSS1qR0EA rPDlpCSBNcyueSwNpjtzfQpj2aV5jKggFlriohYsi5ad+oCIUTeG3spbP2HvyeG+m/0t 1n2iQDG/Li3ItVTIHhV9Z0o5xzAFjhlfNHG+yUlsGC4mJQ8yN3Irwzjt9CA40MiizivY DKvmc0b4oHYhNY4BJp1/nm0dTqmB9ySuN5dpyVqfH8Td6iMDOXVK4nAT2dEHGAN6Pu7s Pg+w== X-Gm-Message-State: AHQUAuaGz+B1sqqfXpPfzqnEtyKpq8UzdL3wGy32plqIDTcA/sJCl/cS zo8PRFa/kaO0VDkV4G+7d6s= X-Google-Smtp-Source: AHgI3IYz4u8vTFp9BgsDSJCu3l1CaxxnAB38rKQgHJPeK8BR5gUDuNkouaUy+C74w9y1LyTxYJLWig== X-Received: by 2002:a63:2ac9:: with SMTP id q192mr1974368pgq.58.1549326197669; Mon, 04 Feb 2019 16:23:17 -0800 (PST) Received: from ubuntu.localdomain ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id 84sm1560976pfk.134.2019.02.04.16.23.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Feb 2019 16:23:16 -0800 (PST) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Mon, 4 Feb 2019 16:23:06 -0800 Message-Id: <1549326187-82147-1-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v4 1/2] dp-packet: Add 'dp_packet_l3_size()'. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The new api will be used in a subsequent patch. Signed-off-by: Darrell Ball --- v4: Added function header comments to the new and existing APIs (Ben). v2: Added patch to series. lib/dp-packet.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 7b85dd9..c297a8f 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -352,10 +352,23 @@ dp_packet_set_l4(struct dp_packet *b, void *l4) b->l4_ofs = l4 ? (char *) l4 - (char *) dp_packet_data(b) : UINT16_MAX; } +/* Returns the size of the packet from the beginning of the L3 header to the + * end of the L3 payload. Hence L2 padding is not included. */ +static inline size_t +dp_packet_l3_size(const struct dp_packet *b) +{ + return OVS_LIKELY(b->l3_ofs != UINT16_MAX) + ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l3(b) + - dp_packet_l2_pad_size(b) + : 0; +} + +/* Returns the size of the packet from the beginning of the L4 header to the + * end of the L4 payload. Hence L2 padding is not included. */ static inline size_t dp_packet_l4_size(const struct dp_packet *b) { - return b->l4_ofs != UINT16_MAX + return OVS_LIKELY(b->l4_ofs != UINT16_MAX) ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l4(b) - dp_packet_l2_pad_size(b) : 0;