From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC7BCA0557; Thu, 9 Jun 2022 09:55:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE18D4069C; Thu, 9 Jun 2022 09:55:23 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 19AF740220 for ; Thu, 9 Jun 2022 09:55:23 +0200 (CEST) Received: from [192.168.1.40] (unknown [188.170.81.145]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 16883302; Thu, 9 Jun 2022 10:55:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 16883302 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1654761322; bh=iYTEIQY8l54g2K8SCHB2v7f5oFjyEMITpNr1ogKxxUM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FbLFbciEfhAyfJumrKFN2wLwLQoCk/X7KI8E4pYu2vYcCNVj6e8hx5YvNRCTtBRC7 rGMo5RUTWIlztPIOTQl22n4CV+VCDZXqUakmFdvZhpWLnYjbeeo4sDb3hVTzenHFSQ Tgxyh49npmaDhDwztAMz4NAfvP2Sn2yh61urXtKc= Message-ID: Date: Thu, 9 Jun 2022 10:55:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v5 7/7] app/testpmd: add Host Shaper command Content-Language: en-US To: Spike Du , matan@nvidia.com, viacheslavo@nvidia.com, orika@nvidia.com, thomas@monjalon.net, Xiaoyun Li , Aman Singh , Yuying Zhang Cc: stephen@networkplumber.org, mb@smartsharesystems.com, dev@dpdk.org, rasland@nvidia.com References: <20220603124821.1148119-1-spiked@nvidia.com> <20220607125942.241379-1-spiked@nvidia.com> <20220607125942.241379-8-spiked@nvidia.com> From: Andrew Rybchenko In-Reply-To: <20220607125942.241379-8-spiked@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Since ethdev patch is factored out from the patch series the rest could go to mlx5 maintainers. On 6/7/22 15:59, Spike Du wrote: > Add command line options to support host shaper configure. > - Command syntax: > mlx5 set port host_shaper avail_thresh_triggered <0|1> rate > > > - Example commands: > To enable avail_thresh_triggered on port 1 and disable current host > shaper: > testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 1 rate 0 > > To disable avail_thresh_triggered and current host shaper on port 1: > testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 0 > > The rate unit is 100Mbps. > To disable avail_thresh_triggered and configure a shaper of 5Gbps on > port 1: > testpmd> mlx5 set port 1 host_shaper avail_thresh_triggered 0 rate 50 > > Add sample code to handle rxq available descriptor threshold event, it > delays a while so that rxq empties, then disables host shaper and > rearms available descriptor threshold event. > > Signed-off-by: Spike Du [snip] > + > +static uint8_t host_shaper_avail_thresh_triggered[RTE_MAX_ETHPORTS]; > +#define SHAPER_DISABLE_DELAY_US 100000 /* 100ms */ > + > +/** > + * Disable the host shaper and re-arm available descriptor threshold event. > + * > + * @param[in] args > + * uint32_t integer combining port_id and rxq_id. > + */ > +static void > +mlx5_test_host_shaper_disable(void *args) > +{ > + uint32_t port_rxq_id = (uint32_t)(uintptr_t)args; > + uint16_t port_id = port_rxq_id & 0xffff; > + uint16_t qid = (port_rxq_id >> 16) & 0xffff; > + struct rte_eth_rxq_info qinfo; > + > + printf("%s disable shaper\n", __func__); > + if (rte_eth_rx_queue_info_get(port_id, qid, &qinfo)) { > + printf("rx_queue_info_get returns error\n"); > + return; > + } > + /* Rearm the available descriptor threshold event. */ > + if (rte_eth_rx_avail_thresh_set(port_id, qid, qinfo.avail_thresh)) { > + printf("config avail_thresh returns error\n"); > + return; > + } > + /* Only disable the shaper when avail_thresh_triggered is set. */ > + if (host_shaper_avail_thresh_triggered[port_id] && > + rte_pmd_mlx5_host_shaper_config(port_id, 0, 0)) > + printf("%s disable shaper returns error\n", __func__); > +} > + > +void > +mlx5_test_avail_thresh_event_handler(uint16_t port_id, uint16_t rxq_id) > +{ > + uint32_t port_rxq_id = port_id | (rxq_id << 16); Nobody guarantees here that port_id refers to an mlx5 port. It could be any port with avail_thres support. > + > + rte_eal_alarm_set(SHAPER_DISABLE_DELAY_US, > + mlx5_test_host_shaper_disable, > + (void *)(uintptr_t)port_rxq_id); > + printf("%s port_id:%u rxq_id:%u\n", __func__, port_id, rxq_id); > +} [snip] > +cmdline_parse_token_string_t cmd_port_host_shaper_mlx5 = > + TOKEN_STRING_INITIALIZER(struct cmd_port_host_shaper_result, > + mlx5, "mlx5"); I think it lucks 'static' keyword (many cases below). [snip]