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 978D745C0D; Wed, 30 Oct 2024 03:29:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3117A42FB9; Wed, 30 Oct 2024 03:29:49 +0100 (CET) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by mails.dpdk.org (Postfix) with ESMTP id 7221F42EC5 for ; Wed, 30 Oct 2024 03:29:48 +0100 (CET) Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-718e9c8bd83so361765b3a.1 for ; Tue, 29 Oct 2024 19:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1730255387; x=1730860187; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=a/rpgk3OK5/mgfj5AfieKfa8MIlacu/9ijP3yuo/WV0=; b=cAP1yiyf3poXAEfFAux3tmh3aSafQJO/XtSrlhvpn7Jj5baSjpTnn/bsFOcaObmEjJ P+hX1dXBSRGL4CURmq4r2TqpAqNRCBrlghQ+/Zv428X12woHqPMgAShlt0whgg9aJXOs KmdHjXuiTX4PJk3sXiFOcYvxtkCZdE/4lGm7pwRF6e67Qqcaz7rfYZVui4ZplDtb3mZ4 Vzyormg6PoCBlhSLXzEqo8fbJqv8HN5onmo0WYMEy5ACBuCe2H+hR8h0WnjxW29pIrXy FScJ4h1rZAa9tXINZhXKTROMUGwhP6FZlTrrAnrjjFcv/udkZppv/yQr+2KoIs8OL4JA FUFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730255387; x=1730860187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a/rpgk3OK5/mgfj5AfieKfa8MIlacu/9ijP3yuo/WV0=; b=cRBGgwSKyIjfxMQkDFgE4gqDuGEjYBrzXhhjSK3TvfmeNN+LkQHtYSLS3Tku4nIxBg zjXpVPvf/Ua4bHFKgBV+dbNYkqj1p7q/ybryM2rKEjznHhIthnxefpVUGvohmNpy9ggM Mghk5ujSt1+4cXAebMxbii37TkMr5MD1JyeBe5CuumwsD4Eb9C7JpvZXq5OpPJWeFkP8 ad0wUtJwNzLRyvznDIRaxx0wmpcPjyKO1TgW08expjUKOtnI9BR1kNJE3bsin1/2xqJv a2VOyOPfyMu1OKV0226irhAhnZowx1tnuCoQJLLQQ5SeVwWJSi1vKiReVuQIpLG7fXWE 8xJg== X-Gm-Message-State: AOJu0Yw+OUY5NIpvO91wJUSRhTK7Hu0BLUyl5+cngcvw1o4MKFdU6hTx huJEeFBYHcgKcNsAhO3sYmTEqk2esTmgNuwMiF3iSx5okLic/vfKGSh8KhqhMpI= X-Google-Smtp-Source: AGHT+IEuG4UE3WiwoqfBUee8oltfD5h9dE4WDBg0GDILmyx5ZxfoL//Z18Q79DGnfIod77U1rKi3xw== X-Received: by 2002:a05:6a00:811:b0:71e:7258:c69b with SMTP id d2e1a72fcca58-720ad2c6791mr1212211b3a.14.1730255387064; Tue, 29 Oct 2024 19:29:47 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72057a219e4sm8581650b3a.175.2024.10.29.19.29.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 19:29:46 -0700 (PDT) Date: Tue, 29 Oct 2024 19:29:45 -0700 From: Stephen Hemminger To: Gregory Etelson Cc: , , =?UTF-8?B?wqA=?= , Aman Singh , Yuying Zhang Subject: Re: [PATCH] testpmd: add hairpin-map parameter Message-ID: <20241029192945.4cfd7d73@hermes.local> In-Reply-To: <20230928133906.711063-1-getelson@nvidia.com> References: <20230928133906.711063-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 On Thu, 28 Sep 2023 16:39:06 +0300 Gregory Etelson wrote: > +static __rte_always_inline > +char *parse_hairpin_map_entry(char *input, char **next) > +{ > + char *tail = strchr(input, ':'); > + > + if (!tail) > + return NULL; > + tail[0] = '\0'; > + *next = tail + 1; > + return input; > +} > + There is no reason to mark this as inline. It is not in fast path. Let compiler decide. > + head = parse_hairpin_map_entry(next, &next); > + if (!head) > + goto err; > + map->rx_port = atoi(head); Use strtoul() to allow checking for invalid number. Seems like the parsing here is following the parsing code pattern that could use strtok_r. > + /* Fail to setup rx queue, return */ > + if (port->port_status == RTE_PORT_HANDLING) > + port->port_status = RTE_PORT_STOPPED; > + else > + fprintf(stderr, > + "Port %d can not be set back to stopped\n", pi); > + fprintf(stderr, > + "Port %d failed to configure hairpin on rxq %u.\n" > + "Peer port: %u peer txq: %u\n", > + pi, qi, peer_tx_port, i); Minor nit, port should be printed with %u since it is unsigned. Lots of testpmd code gets this wrong, and compiler doesn't care. > +/* Configure the Rx and Tx hairpin queues for the selected port. */ > +static int > +setup_hairpin_queues(portid_t pi, portid_t p_pi, uint16_t cnt_pi) > +{ > + return !hairpin_multiport_mode ? > + setup_legacy_hairpin_queus(pi, p_pi, cnt_pi) : > + setup_mapped_harpin_queues(pi); > +} It is clearer to use an if statement in this case. Also, better to write positive rather than negative logic. if (hairpin_multiport_mode) return setup_mapped_hairpin_queues(pi); else return setup_legacy_hairpin_queus(pi, p_pi, cnt_pi);