From patchwork Fri Oct 16 13:25:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 55102 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f69.google.com (mail-lf0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 87BD622EAC for ; Fri, 16 Oct 2015 13:26:10 +0000 (UTC) Received: by lffv3 with SMTP id v3sf17999835lff.1 for ; Fri, 16 Oct 2015 06:26:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=1sDTCNhrEYLkU5I7LQCS+/YMDdZdZRPjTselsenTPpE=; b=hmkCJk2B/XgPxMwHNO1jnsn8bO+bqV6jXQFDi8Hzcy+ORjGy9jD9qIduejM2gPKUyM AaO9zNboT1isHfr3xQPEQ4yDluV4s99Xoat2+1i/o2SMALc/dRyfWWmVQ31Y8eJndtXM EuWN19Wsp3yyPwS5Pse1yLGXBPWnzWy0lf6YUZ+koLntfoJv4OiGMBBjx+4C5/OcNTv0 JDAqrTDtldNzEy8mTMNhy0uSlaYhMNEe3z+OOPgcz3i4UUBz1cyNaFlMHrvnCfcvF2Y7 kPDHCM71hcFHBJPQn8to8nLmd3NBFF6JlXRFLnr0i/dxZWPCT6YTjX+kmtWcbV8p5QnF AGFA== X-Gm-Message-State: ALoCoQne4GH+j/GRsalYB67qF2MZJTTfBI65Vys8IGORwYkpWCvw//8jGNcbUn4OXhQ3pDGkFSaq X-Received: by 10.112.12.132 with SMTP id y4mr3552905lbb.0.1445001969424; Fri, 16 Oct 2015 06:26:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.84.147 with SMTP id i141ls154548lfb.15.gmail; Fri, 16 Oct 2015 06:26:09 -0700 (PDT) X-Received: by 10.112.150.201 with SMTP id uk9mr8453840lbb.102.1445001969209; Fri, 16 Oct 2015 06:26:09 -0700 (PDT) Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id pr8si12923441lbc.15.2015.10.16.06.26.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 06:26:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; Received: by lffy185 with SMTP id y185so79518603lff.2 for ; Fri, 16 Oct 2015 06:26:08 -0700 (PDT) X-Received: by 10.25.28.81 with SMTP id c78mr5432466lfc.29.1445001968726; Fri, 16 Oct 2015 06:26:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1288373lbq; Fri, 16 Oct 2015 06:26:07 -0700 (PDT) X-Received: by 10.55.20.150 with SMTP id 22mr18895598qku.41.1445001967425; Fri, 16 Oct 2015 06:26:07 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 71si17850499qkz.106.2015.10.16.06.26.07; Fri, 16 Oct 2015 06:26:07 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 0D34561D67; Fri, 16 Oct 2015 13:26:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 74F5962C28; Fri, 16 Oct 2015 13:25:39 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B40A962C20; Fri, 16 Oct 2015 13:25:35 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 2F68B61D67 for ; Fri, 16 Oct 2015 13:25:34 +0000 (UTC) Received: by lffy185 with SMTP id y185so79510650lff.2 for ; Fri, 16 Oct 2015 06:25:33 -0700 (PDT) X-Received: by 10.25.165.84 with SMTP id o81mr5460817lfe.80.1445001933116; Fri, 16 Oct 2015 06:25:33 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id lc3sm2846571lbc.3.2015.10.16.06.25.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Oct 2015 06:25:32 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 16 Oct 2015 16:25:26 +0300 Message-Id: <1445001927-13916-2-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445001927-13916-1-git-send-email-maxim.uvarov@linaro.org> References: <1445001927-13916-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 1/2] api: define pktio statistics api X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Maxim Uvarov --- include/odp/api/packet_io_stats.h | 166 +++++++++++++++++++++++++ platform/linux-generic/include/odp/packet_io.h | 1 + 2 files changed, 167 insertions(+) create mode 100644 include/odp/api/packet_io_stats.h diff --git a/include/odp/api/packet_io_stats.h b/include/odp/api/packet_io_stats.h new file mode 100644 index 0000000..94af18c --- /dev/null +++ b/include/odp/api/packet_io_stats.h @@ -0,0 +1,166 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Packet IO + */ + +#ifndef ODP_API_PACKET_IO_STATS_H_ +#define ODP_API_PACKET_IO_STATS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup odp_packet_io ODP PACKET IO + * @{ + */ + +/** + * Packet IO statistics + * + * Packet IO statictics counters follow RFCs for Management Information Base + * (MIB)for use with network management protocols in the Internet community: + * https://tools.ietf.org/html/rfc3635 + * https://tools.ietf.org/html/rfc2863 + * https://tools.ietf.org/html/rfc2819 + */ +typedef struct odp_pktio_stats_t { + /** + * The number of octets in valid MAC frames received on this interface, + * including the MAC header and FCS. See ifHCInOctets counter + * description in RFC 3635 for details. + */ + uint64_t in_octets; + /** + * The number of packets, delivered by this sub-layer to a higher + * (sub-)layer, which were not addressed to a multicast or broadcast + * address at this sub-layer. See InUcastPkts in RFC 2863. + */ + uint64_t in_ucast_pkts; + /** + * The number of inbound packets which were chosen to be discarded + * even though no errors had been detected to preven their being + * deliverable to a higher-layer protocol. One possible reason for + * discarding such a packet could be to free up buffer space. + * See InDiscards in RFC 2863. + */ + uint64_t in_discards; + /** + * The sum for this interface of AlignmentErrors, FCSErrors, FrameTooLongs, + * InternalMacReceiveErrors. See InErrors in RFC 3635. + */ + uint64_t in_errors; + /** + * For packet-oriented interfaces, the number of packets received via + * the interface which were discarded because of an unknown or + * unsupported protocol. For character-oriented or fixed-length + * interfaces that support protocol multiplexing the number of + * transmission units received via the interface which were discarded + * because of an unknown or unsupported protocol. For any interface + * that does not support protocol multiplexing, this counter will always + * be 0. See InUnknownProtos in RFC 2863. + */ + uint64_t in_unknown_protos; + /** + * The number of octets transmitted in valid MAC frames on this + * interface, including the MAC header and FCS. This does include + * the number of octets in valid MAC Control frames transmitted on + * this interface. See OutOctets in RFC 3635. + */ + uint64_t out_octets; + /** + * The total number of packets that higher-level protocols requested + * be transmitted, and which were not addressed to a multicast or + * broadcast address at this sub-layer, including those that were + * discarded or not sent. does not include MAC Control frames. + * See OutUcastPkts in RFC 2863, 3635. + */ + uint64_t out_ucast_pkts; + /** + * The number of outbound packets which were chosen to be discarded + * even though no errors had been detected to prevent their being + * transmitted. One possible reason for discarding such a packet could + * be to free up buffer space. See OutDiscards in RFC 2863. + */ + uint64_t out_discards; + /** + * The sum for this interface of SQETestErrors, LateCollisions, + * ExcessiveCollisions, InternalMacTransmitErrors and + * CarrierSenseErrors. See OutErrors in RFC 3635. + */ + uint64_t out_errors; +} odp_pktio_stats_t; + +/** Bit in odp_pktio_stats_mask_t defines if in_octets counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_IN_OCTETS (1 << 0) +/** Bit in odp_pktio_stats_mask_t defines if in_ucast_pkts counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_IN_UCAST_PKTS (1 << 1) +/** Bit in odp_pktio_stats_mask_t defines if in_discards counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_IN_DISCARDS (1 << 2) +/** Bit in odp_pktio_stats_mask_t defines if in_errors counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_IN_ERRORS (1 << 3) +/** Bit in odp_pktio_stats_mask_t defines if in_unknown_protos counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_IN_UPROTOS (1 << 4) +/** Bit in odp_pktio_stats_mask_t defines if out_octets counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_OUT_OCTETS (1 << 5) +/** Bit in odp_pktio_stats_mask_t defines if out_ucast_pkts counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_OUT_UCAST_PKTS (1 << 6) +/** Bit in odp_pktio_stats_mask_t defines if out_discards counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_OUT_DISCARDS (1 << 7) +/** Bit in odp_pktio_stats_mask_t defines if out_errors counter + * of odp_pktio_stats_t struct is supported */ +#define ODP_PKTIO_STATS_OUT_ERRORS (1 << 8) + +/** + * Mask type of supported counters by platform, defined as: + * ODP_PKTIO_STATS_xxxx + */ +typedef uint32_t odp_pktio_stats_mask_t; + +/** + * Get statistics for pktio handle + * + * @param pktio Packet IO handle + * @param[out] *stats Output buffer for counters + * @param[out] *mask Output buffer for counters supported mask + * @retval 0 on success + * @retval <0 on failure + */ +int odp_pktio_stats(odp_pktio_t pktio, + odp_pktio_stats_t *stats, + odp_pktio_stats_mask_t *mask); + +/** + * Reset statistics for pktio handle + * + * @param pktio Packet IO handle + * @param mask Counters mask to reset + * @retval 0 on success + * @retval <0 on failure + * + */ +int odp_pktio_stats_reset(odp_pktio_t pktio, odp_pktio_stats_mask_t mask); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/packet_io.h b/platform/linux-generic/include/odp/packet_io.h index 1d690f5..18f8e78 100644 --- a/platform/linux-generic/include/odp/packet_io.h +++ b/platform/linux-generic/include/odp/packet_io.h @@ -33,6 +33,7 @@ extern "C" { */ #include +#include #ifdef __cplusplus }