From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by dpdk.org (Postfix) with ESMTP id 256895A8B for ; Wed, 27 May 2015 20:10:21 +0200 (CEST) Received: by pdbki1 with SMTP id ki1so22614362pdb.1 for ; Wed, 27 May 2015 11:10:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mzniZmJc92Ud6R6pISt8gDgj2fUqEcsBsrjoCElL1hE=; b=Rn2+jIrfsmSYyM6wdZvZ1plcs3b1+LF1iqVXl++CErltfPLlXnYLdG5aO1rchPIdLY vM50q/GaJ+6cL4NB7Da8wt4vcFXIu6sZo229AqqLsgRJ1rqEI3497HHgFa2AQTTrkEz8 SRz5RX7Bcz3GVFUn/r3OgYQ0dm9uoOlztUhDhyyEXuvx6XiA0x3iESsVhHyHVAjM8NDC wSiLaoFZmE9iSXFxfO1/sUyMNYZ/O0FZzh0qKYHccY7ZTQ5kqGbcRvHkYFt0TuDTvJ7X XNA63Jx3l/Scww+Q70tLuGWyXquYdwS6Ui1Y3zreIt7nWhPioHO6yRIBCZO7voOAWPs3 EA/g== X-Gm-Message-State: ALoCoQlSkR1Oc/9VgLssr/hOJtOI/L4Z6Gg1vaYP+uzyrt94MboU4ZobjBm6/hVTzVftylfI6Ouy X-Received: by 10.68.69.39 with SMTP id b7mr61356200pbu.35.1432750220563; Wed, 27 May 2015 11:10:20 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id db1sm3008254pdb.50.2015.05.27.11.10.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 May 2015 11:10:19 -0700 (PDT) From: Stephen Hemminger To: cristian.dumitrescu@intel.com Date: Wed, 27 May 2015 11:10:16 -0700 Message-Id: <1432750217-4186-5-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1432750217-4186-1-git-send-email-stephen@networkplumber.org> References: <1432750217-4186-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH 4/5] rte_sched: hide structure of port hierarchy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 May 2015 18:10:21 -0000 Right now the scheduler hierarchy is encoded as a bitfield that is visible as part of the ABI. This creates an barrier limiting future expansion of the hierarchy. As a transistional step. hide the actual layout of the hierarchy and mark the exposed structure as deprecated. This will allow for expansion in later release. Signed-off-by: Stephen Hemminger --- lib/librte_sched/rte_sched.c | 54 ++++++++++++++++++++++++++++++++++ lib/librte_sched/rte_sched.h | 54 ++++++++++------------------------ lib/librte_sched/rte_sched_version.map | 3 ++ 3 files changed, 73 insertions(+), 38 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index b1655b4..9c9419d 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -184,6 +184,21 @@ enum grinder_state { e_GRINDER_READ_MBUF }; +/* + * Path through the scheduler hierarchy used by the scheduler enqueue + * operation to identify the destination queue for the current + * packet. Stored in the field pkt.hash.sched of struct rte_mbuf of + * each packet, typically written by the classification stage and read + * by scheduler enqueue. + */ +struct __rte_sched_port_hierarchy { + uint32_t queue:2; /**< Queue ID (0 .. 3) */ + uint32_t traffic_class:2; /**< Traffic class ID (0 .. 3)*/ + uint32_t pipe:20; /**< Pipe ID */ + uint32_t subport:6; /**< Subport ID */ + uint32_t color:2; /**< Color */ +}; + struct rte_sched_grinder { /* Pipe cache */ uint16_t pcache_qmask[RTE_SCHED_GRINDER_PCACHE_SIZE]; @@ -910,6 +925,45 @@ rte_sched_pipe_config(struct rte_sched_port *port, return 0; } +void +rte_sched_port_pkt_write(struct rte_mbuf *pkt, + uint32_t subport, uint32_t pipe, uint32_t traffic_class, + uint32_t queue, enum rte_meter_color color) +{ + struct __rte_sched_port_hierarchy *sched + = (struct __rte_sched_port_hierarchy *) &pkt->hash.sched; + + sched->color = (uint32_t) color; + sched->subport = subport; + sched->pipe = pipe; + sched->traffic_class = traffic_class; + sched->queue = queue; +} + +void +rte_sched_port_pkt_read_tree_path(const struct rte_mbuf *pkt, + uint32_t *subport, uint32_t *pipe, + uint32_t *traffic_class, uint32_t *queue) +{ + const struct __rte_sched_port_hierarchy *sched + = (const struct __rte_sched_port_hierarchy *) &pkt->hash.sched; + + *subport = sched->subport; + *pipe = sched->pipe; + *traffic_class = sched->traffic_class; + *queue = sched->queue; +} + + +enum rte_meter_color +rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt) +{ + const struct __rte_sched_port_hierarchy *sched + = (const struct __rte_sched_port_hierarchy *) &pkt->hash.sched; + + return (enum rte_meter_color) sched->color; +} + int rte_sched_subport_read_stats(struct rte_sched_port *port, uint32_t subport_id, diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h index e6bba22..f7c0b8e 100644 --- a/lib/librte_sched/rte_sched.h +++ b/lib/librte_sched/rte_sched.h @@ -195,17 +195,19 @@ struct rte_sched_port_params { #endif }; -/** Path through the scheduler hierarchy used by the scheduler enqueue operation to -identify the destination queue for the current packet. Stored in the field hash.sched -of struct rte_mbuf of each packet, typically written by the classification stage and read by -scheduler enqueue.*/ +/* + * Path through scheduler hierarchy + * + * Note: direct access to internal bitfields is deprecated to allow for future expansion. + * Use rte_sched_port_pkt_read/write API instead + */ struct rte_sched_port_hierarchy { uint32_t queue:2; /**< Queue ID (0 .. 3) */ uint32_t traffic_class:2; /**< Traffic class ID (0 .. 3)*/ uint32_t pipe:20; /**< Pipe ID */ uint32_t subport:6; /**< Subport ID */ uint32_t color:2; /**< Color */ -}; +} __attribute__ ((deprecated)); /* * Configuration @@ -328,11 +330,6 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, struct rte_sched_queue_stats *stats, uint16_t *qlen); -/* - * Run-time - * - ***/ - /** * Scheduler hierarchy path write to packet descriptor. Typically called by the * packet classification stage. @@ -348,18 +345,10 @@ rte_sched_queue_read_stats(struct rte_sched_port *port, * @param queue * Queue ID within pipe traffic class (0 .. 3) */ -static inline void +void rte_sched_port_pkt_write(struct rte_mbuf *pkt, - uint32_t subport, uint32_t pipe, uint32_t traffic_class, uint32_t queue, enum rte_meter_color color) -{ - struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->hash.sched; - - sched->color = (uint32_t) color; - sched->subport = subport; - sched->pipe = pipe; - sched->traffic_class = traffic_class; - sched->queue = queue; -} + uint32_t subport, uint32_t pipe, uint32_t traffic_class, + uint32_t queue, enum rte_meter_color color); /** * Scheduler hierarchy path read from packet descriptor (struct rte_mbuf). Typically @@ -378,24 +367,13 @@ rte_sched_port_pkt_write(struct rte_mbuf *pkt, * Queue ID within pipe traffic class (0 .. 3) * */ -static inline void -rte_sched_port_pkt_read_tree_path(struct rte_mbuf *pkt, uint32_t *subport, uint32_t *pipe, uint32_t *traffic_class, uint32_t *queue) -{ - struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->hash.sched; - - *subport = sched->subport; - *pipe = sched->pipe; - *traffic_class = sched->traffic_class; - *queue = sched->queue; -} - -static inline enum rte_meter_color -rte_sched_port_pkt_read_color(struct rte_mbuf *pkt) -{ - struct rte_sched_port_hierarchy *sched = (struct rte_sched_port_hierarchy *) &pkt->hash.sched; +void +rte_sched_port_pkt_read_tree_path(const struct rte_mbuf *pkt, + uint32_t *subport, uint32_t *pipe, + uint32_t *traffic_class, uint32_t *queue); - return (enum rte_meter_color) sched->color; -} +enum rte_meter_color +rte_sched_port_pkt_read_color(const struct rte_mbuf *pkt); /** * Hierarchical scheduler port enqueue. Writes up to n_pkts to port scheduler and diff --git a/lib/librte_sched/rte_sched_version.map b/lib/librte_sched/rte_sched_version.map index 9f74e8b..6626a74 100644 --- a/lib/librte_sched/rte_sched_version.map +++ b/lib/librte_sched/rte_sched_version.map @@ -17,6 +17,9 @@ DPDK_2.0 { rte_sched_queue_read_stats; rte_sched_subport_config; rte_sched_subport_read_stats; + rte_sched_port_pkt_write; + rte_sched_port_pkt_read_tree_path; + rte_sched_port_pkt_read_color; local: *; }; -- 2.1.4